How to Apply an Access Report Filter When the Report Opens
Question details
The user needs to prompt for or select a filter condition, such as a Yes/No field, before generating and opening a Microsoft Access report.

- Product
- Microsoft Access
- Device & OS
- not provided
- Scenario
- Generating a customized database report based on user input, specifically filtering records where a boolean field is set to Yes before the report opens.
- Observed behavior
- The goal is to apply a dynamic filter conditionally upon opening, rather than opening the report with all records displayed by default.
Ensure you have basic familiarity with Access Forms, the Visual Basic for Applications (VBA) editor, and the Design View of your database.
Use a Form with a Command Button and WhereCondition
Create a user-friendly form with a checkbox that passes a specific filter string to the report using the DoCmd.OpenReport method.
This method is highly recommended as it keeps the user interface clean and separates the filtering logic from the report itself. By using a form, you can easily expand criteria later if needed.
Open your Access database, navigate to the Create tab, and create a new Form. Add a Check Box control to the form and name it 'chkYesNo' in the Property Sheet.
Add a Command Button to the same form and name it 'cmdReport'. This button will be used to trigger the report generation.
Right-click the command button, select Build Event, and choose Code Builder. In the VBA editor, add the following logic to the Click event: Dim strWhere As String. Then, add an If statement: If Me.chkYesNo Then strWhere = "[blnMyYesNo] = True".
Directly below the If statement, add the command to open the report: DoCmd.OpenReport ReportName:="YourReportName", View:=acViewPreview, WhereCondition:=strWhere. If the checkbox is unchecked, strWhere remains empty and all records are shown.

Prompt the User via the Report_Open Event
Directly prompt the user with a message box when they attempt to open the report, configuring the report's internal filter based on their response.
Looking for a Free and Powerful Office Suite?
While Microsoft Access is a specialized tool for database management, you likely need a reliable suite for documents, spreadsheets, and presentations. WPS Office is a lightweight, fully compatible alternative to Microsoft Office that meets all your daily productivity needs for free.
- 1. Download WPS Office: Visit the official WPS website to download the free installation package for your operating system.
- 2. Install and Launch: Follow the on-screen instructions to install the suite in seconds, then open the unified workspace.
- 3. Open Your Files Seamlessly: Drag and drop your existing .docx, .xlsx, or .pptx files directly into WPS Office to continue working with complete formatting preserved.

Frequently Asked Questions
Can I filter an Access report without using VBA?
Yes, you can use parameter queries as the data source for your report. By entering a prompt like [Enter Yes or No:] in the criteria row of your query, Access will automatically ask for input before opening the report.
What happens if I leave the WhereCondition blank in DoCmd.OpenReport?
If the WhereCondition parameter is left blank or passed as an empty string, the report will open without any filters applied, displaying all records from its underlying table or query.
How do I filter a report based on a text field instead of a Yes/No field?
To filter based on text, you must wrap the criteria string in single quotes within your VBA code. For example: strWhere = "[Category] = 'Sales'".
Why is my report opening blank after applying a filter?
This usually happens if the criteria provided in the WhereCondition does not match any records in the database, or if the field name referenced in the VBA string is spelled incorrectly.




