How to Use a Multiselect ListBox in a Parameter Query in Access
Question details
The user needs to pass multiple selected values from a multiselect ListBox on a form to a parameter query to filter records.

- Product
- Microsoft Access
- Device & OS
- not provided
- Scenario
- Building a custom form where users can select one, multiple, or all holding company IDs from a list to filter query or report results.
- Observed behavior
- Standard queries only accept single values directly from form controls, requiring a method to capture and process multiple selections into query criteria.
Ensure you are comfortable with basic VBA (Visual Basic for Applications) and opening the Access form in Design View, as multiselect ListBoxes require code to process their values.
Process the ItemsSelected Collection with VBA
Iterate through the selected items in the ListBox using a VBA loop to build a custom filter string for your queries or reports.
A multiselect ListBox does not hold a single value that a standard parameter query can reference. Instead, you must use a VBA script attached to a button to loop through its ItemsSelected collection, extract the chosen values, and build a valid SQL WHERE clause.
Right-click your form in the Navigation Pane and select 'Design View'. Ensure your ListBox has its 'Multi Select' property set to Simple or Extended.
Drag a Button control onto your form from the Form Design ribbon. This will be used to trigger the query.
Select the newly added button, open the Property Sheet (F4), go to the 'Event' tab, click the ellipsis (...) next to 'On Click', and choose 'Code Builder'.
Write a VBA loop utilizing 'Me.YourListBoxName.ItemsSelected' to concatenate the selected values into a comma-separated string format, such as 'IN (1, 2, 3)'.
Pass the generated string variable as the 'WhereCondition' argument using 'DoCmd.OpenReport' or 'DoCmd.OpenForm', which acts as the dynamic parameter.

Update a QueryDef SQL Statement Dynamically
Modify the SQL code of a saved query on-the-fly using the DAO QueryDef object before opening it.
Looking for a Free and Lightweight Office Alternative?
While Microsoft Access manages relational databases natively within MS Office, WPS Office offers a completely free, highly compatible alternative for your spreadsheet, document, and presentation needs. Export your database queries to WPS Spreadsheet for seamless data analysis with a familiar, lightweight UI.
- 1. Download WPS Office: Visit the official WPS Office website and click the free download button.
- 2. Install the Software: Run the lightweight installation file and follow the quick setup wizard.
- 3. Open Exported Files: Easily open, view, and analyze data exported from your databases with native Excel format compatibility.

Frequently Asked Questions
Why can't I just put the ListBox name directly in the query criteria?
When an Access ListBox has its Multi Select property enabled, its value is always treated as Null. You cannot reference it directly in a query's criteria grid like [Forms]![MyForm]![MyListBox]. You must use VBA to loop through the ItemsSelected collection instead.
How can I add a Select All option to my multiselect ListBox?
You can add a command button labeled 'Select All' to your form. In its VBA Click event, use a For loop from 0 to Me.YourListBox.ListCount - 1, setting Me.YourListBox.Selected(i) = True for every item index.
Can I pass a comma-separated string to an IN clause via a standard query parameter?
No, standard Access parameter queries do not evaluate a single string parameter (like '1,2,3') as a list of independent values for an IN clause. It treats it as one literal string. You must reconstruct the query using QueryDef or apply a filter string when opening a form/report.




