How to Pass Form Criteria to an Access Report Query
Question details
The user needs to pass a selected value from a form combo box as criteria to an Access report query upon clicking a command button.

- Product
- Microsoft Access
- Device & OS
- not provided
- Scenario
- Dynamically filtering a report based on user selection in a form combo box before opening it.
- Observed behavior
- The report opens and displays records dynamically filtered by the criteria specified in the form controls.
Ensure your Access database contains the target report and a form configured with the necessary input controls, such as a combo box (e.g., cboOrderID), and a command button to trigger the action.
Use VBA and the OpenReport WhereCondition Argument
This is the most flexible and recommended method, allowing you to build the filter string dynamically in VBA before executing the command to open the report.
By utilizing the WhereCondition argument in the DoCmd.OpenReport method, you can pass parameters seamlessly without modifying the underlying query of the report.
Right-click your form in the navigation pane and select 'Design View'. Select the command button you want to use to open the report.
Open the Property Sheet (F4), navigate to the 'Event' tab, click the 'On Click' property, select '[Event Procedure]', and click the ellipsis (...) button to open the VBA Editor.
In the VBA window, declare a string variable to hold your SQL WHERE clause by typing: Dim strWhere As String.
Assign the value from your combo box to the string. For numeric values, use: strWhere = "OrderID = " & Me.cboOrderID. For text values, enclose in single quotes: strWhere = "City = '" & Me.cboCity & "'". For dates, use hash symbols: strWhere = "OrderDate = #" & Me.txtDate & "#".
Pass the string variable into the OpenReport command by adding this line: DoCmd.OpenReport "YourReportName", acViewPreview, , strWhere.

Reference the Form Control Directly in the Report Query
A simple approach that requires zero VBA coding, where the report's underlying query directly extracts its criteria from the open form.
Discover WPS Office for Your Data and Document Needs
While Microsoft Access manages your complex databases, WPS Office is the perfect free, lightweight alternative for managing exported data, business reports, and daily documents. Enjoy seamless compatibility with Microsoft formats and a highly familiar user interface.
- 1. Export your Access data: In Microsoft Access, export your generated report or table as an Excel workbook (.xlsx).
- 2. Open in WPS Spreadsheet: Launch WPS Office and open your exported file to easily visualize, chart, and share your data.

Frequently Asked Questions
How do I pass multiple criteria to an Access report from a form?
You can string together multiple conditions in your VBA WhereCondition using SQL AND/OR operators. For example: strWhere = "Status = 'Active' AND CategoryID = " & Me.cboCategory. Pass this combined string to the OpenReport command.
Why does Access ask for a parameter value when I open my report?
This typically happens if a field name or control name is misspelled in your query or WhereCondition. Double-check that the syntax Forms!FormName!ControlName perfectly matches the actual spelling of your form and controls.
How do I handle empty combo boxes so the report shows all records?
In your VBA code, you can use an IF statement to check if the combo box is null. If it is null, skip building the WhereCondition and run DoCmd.OpenReport without the filter argument, which will output all records.




