logo
search
Others

How to Filter a Microsoft Access Report Using a List Box Value

John WilsonJohn Wilson Oct 13, 2026 869 views

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.

How to Filter a Microsoft Access Report Using a List Box Value
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.
Before you start

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.

Solution 1Recommended

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.

1
Open the Form in Design View

Right-click your starting form (e.g., 'Start') in the Navigation Pane and select 'Design View'.

2
Access the Command Button Properties

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

3
Choose Code Builder

If prompted, select 'Code Builder' to open the VBA editor for that button's click event.

4
Insert the DoCmd Code

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.

5
Save and Test

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.

Use DoCmd.OpenReport with a WhereCondition in VBA
Column Indexing: The Column property in Microsoft Access is zero-based. This means Column(0) refers to the first column in the list box, Column(1) refers to the second, and so forth. Ensure you are referencing the correct column that contains your filter criteria.
Free Microsoft Office alternative

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. 1. Download and Install WPS Office: Visit the official WPS website to download the free suite and install it on your device.
  2. 2. Import Your Data: Export your Microsoft Access tables as CSV or Excel files, and open them instantly in WPS Spreadsheet.
  3. 3. Filter and Generate Reports: Use the built-in Data Filter and PivotTable features to dynamically slice, sort, and visualize your data effortlessly.
Powerful Spreadsheet tools to easily filter data and create dynamic reports without complex VBA coding.Seamless compatibility with Microsoft Excel (.xlsx) formats for easy data migration.Lightweight, completely free to download, and offers a familiar interface that requires zero learning curve.
microsoft office alternative - wps office

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