logo
search
Others

How to Pass Form Criteria to an Access Report Query

Aamir Naveed AkramAamir Naveed Akram Oct 10, 2026 868 views

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.

How to Pass Form Criteria to an Access Report Query
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.
Before you start

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.

Solution 1Recommended

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.

1
Open the form in Design View

Right-click your form in the navigation pane and select 'Design View'. Select the command button you want to use to open the report.

2
Access the VBA Event Builder

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.

3
Declare the criteria string variable

In the VBA window, declare a string variable to hold your SQL WHERE clause by typing: Dim strWhere As String.

4
Build the WhereCondition 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 & "#".

5
Execute the OpenReport command

Pass the string variable into the OpenReport command by adding this line: DoCmd.OpenReport "YourReportName", acViewPreview, , strWhere.

Use VBA and the OpenReport WhereCondition Argument
Format Check: Always ensure your string concatenation includes proper spacing, especially around the equals sign, to avoid syntax errors.
Free Microsoft Office alternative

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. 1. Export your Access data: In Microsoft Access, export your generated report or table as an Excel workbook (.xlsx).
  2. 2. Open in WPS Spreadsheet: Launch WPS Office and open your exported file to easily visualize, chart, and share your data.
Easily format and manage tabular reports exported from Access databasesFully compatible with Microsoft Excel (.xlsx), Word, and PowerPoint formatsLightweight suite that installs quickly and runs smoothly on older hardwareFamiliar user interface that requires zero learning curve
QA img-9

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.