How to Filter a Microsoft Access Report Using a List Box Value
Question details
The user needs to filter a Microsoft Access report dynamically based on a value selected from a list box on a separate form.

- Product
- Microsoft Access
- Device & OS
- not provided
- Scenario
- Creating a customized report view triggered by a user's selection on a form interface without permanently modifying the underlying database queries.
- Observed behavior
- The goal is to apply a filter temporarily in memory when opening the report using the selected list box value as the criteria.
Ensure your list box is populated with data and note the exact name of the list box, the form it resides on, and the report you wish to open.
Use DoCmd.OpenReport with a WhereCondition in VBA
The most robust method to filter a report dynamically is by using VBA on a command button to pass the list box value into the WhereCondition argument of the DoCmd.OpenReport method.
By utilizing the WhereCondition argument, you avoid altering the underlying query definition. Access simply applies the specified SQL WHERE clause on the fly when rendering the report.
You can reference the list box value directly in your VBA code using the Column() property, which is especially useful if your bound value (like an ID) is not the first visible column.
Right-click your starting form (e.g., 'Start') in the Navigation Pane and select 'Design View'.
Select the command button that triggers the report to open. Press F4 to open the Property Sheet, navigate to the 'Event' tab, and click the ellipsis (...) next to 'On Click'.
If prompted, select 'Code Builder' to open the VBA editor for that button's click event.
Type the following code: DoCmd.OpenReport "YourReportName", acViewReport, , "ReportField = " & Forms!YourFormName!YourListBoxName.Column(0). Replace 'YourReportName', 'ReportField', 'YourFormName', and 'YourListBoxName' with your actual database object names.
Save the VBA module, switch back to Form View, select an item in the list box, and click the button to see your filtered report.

Try WPS Office for Simplified Data Reporting
If you find Microsoft Access VBA too complex for everyday data filtering, consider using WPS Spreadsheet. It offers a highly intuitive interface for data manipulation, filtering, and pivot tables, making it an excellent, lightweight alternative for managing reports.
- 1. Download and Install WPS Office: Visit the official WPS website to download the free suite and install it on your device.
- 2. Import Your Data: Export your Microsoft Access tables as CSV or Excel files, and open them instantly in WPS Spreadsheet.
- 3. Filter and Generate Reports: Use the built-in Data Filter and PivotTable features to dynamically slice, sort, and visualize your data effortlessly.

Frequently Asked Questions
Can I filter an Access report using multiple selections from a list box?
Yes, but it requires more complex VBA code. You must loop through the ItemsSelected collection of the list box to build a comma-separated string, and then use the IN() SQL operator in your WhereCondition.
Why is my list box returning a null error when I click the report button?
This error typically occurs if no item is highlighted in the list box before clicking the button. You can add a VBA validation check like If IsNull(Me.lstYourListBox) Then MsgBox "Please select an item." to prevent this.
Will using this VBA method permanently alter my saved query or report?
No. The WhereCondition argument used in DoCmd.OpenReport only applies the filter in memory for that specific instance. Your original query and report definitions remain unchanged.
What if the filter value in my list box is text instead of a number?
If the filter criteria is a text string, you must wrap the concatenated value in single quotes within the VBA code. For example: "ReportField = '" & Forms!YourFormName!YourListBoxName.Column(0) & "'".




