'Build up the description from the text in the visible column. 'Build up the filter from the bound column (hidden). 'Loop through the ItemsSelected in the list box. 'strDelim = """" 'Delimiter appropriate to field type. 'Purpose: Open the report filtered to the items selected in the list box.ĭim strWhere As String 'String to use as WhereConditionĭim strDescrip As String 'Description of WhereConditionĭim strDelim As String 'Delimiter for this field type.ĭim strDoc As String 'Name of report to open. The code builds a description of the filter, and passes it with OpenArgs. Add a text box to the Report Header section, and set its Control Source property to: Access 2002 and later only: Open the Products by Category report in design view.Paste the code below into the event procedure.Click the Build button (.) beside the On Click property.Add a command button, with these properties:.SELECT Categories.CategoryID, Categories.CategoryNameįROM Categories ORDER BY Categories.CategoryName Create a new form, not bound to any table or query.Open the query named Products by Category in design view, and add Categories.CategoryID to the grid.This example uses the Products by Category report in the Northwind sample database. Instead, loop through the ItemsSelected collection of the list box, generating a string to use with the IN operator in the WHERE clause of your SQL statement. You cannot do that with a multi-select list box.
With a normal list box or text box, you can limit your report merely by placing a reference to the control in the Criteria row of its query, e.g.
#MICROSOFT ACCESS PRODUCT SELECTION HOW TO#
This article explains how to use a multi-select list box to select several items at once, and open a report limited to those items. Use a multi-select list box to filter a report Microsoft Access tips: Use a multi-select list box to filter a report Microsoft Access Tips for Serious Users