logo
search
Others

How to Use a Multiselect ListBox in a Parameter Query in Access

Camila MilosovichCamila Milosovich Oct 13, 2026 868 views

Question details

The user needs to pass multiple selected values from a multiselect ListBox on a form to a parameter query to filter records.

How to Use a Multiselect ListBox in a Parameter Query
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.
Before you start

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.

Solution 1Recommended

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.

1
Open Form Design View

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.

2
Add a Command Button

Drag a Button control onto your form from the Form Design ribbon. This will be used to trigger the query.

3
Open the VBA Code Builder

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'.

4
Write the Loop Code

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)'.

5
Apply the Criteria

Pass the generated string variable as the 'WhereCondition' argument using 'DoCmd.OpenReport' or 'DoCmd.OpenForm', which acts as the dynamic parameter.

Process the ItemsSelected Collection with VBA
Handling Data Types: If the selected values are text strings rather than numeric IDs, remember to wrap each value in single quotes within your VBA loop (e.g., 'IN (''CompanyA'', ''CompanyB'')').
Free Microsoft Office alternative

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. 1. Download WPS Office: Visit the official WPS Office website and click the free download button.
  2. 2. Install the Software: Run the lightweight installation file and follow the quick setup wizard.
  3. 3. Open Exported Files: Easily open, view, and analyze data exported from your databases with native Excel format compatibility.
High compatibility with Microsoft Office file formats (.xlsx, .docx, .pptx).Lightweight installation and incredibly fast startup times.Familiar tabbed user interface for easy navigation and seamless migration.Powerful spreadsheet data processing features to analyze your exported database query results.
microsoft office alternative - wps office

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.