How to Print a Filtered Report from Multiple Forms in Microsoft Access
Question details
The user wants to find a way to use a single command button across multiple Microsoft Access forms to open or print the same report, specifically filtered to display only the current record.

- Product
- Microsoft Access
- Device & OS
- not provided
- Scenario
- Generating, printing, or emailing a specific report restricted to the currently active record directly from a form interface.
- Observed behavior
- A programmatic solution using VBA is required to dynamically pass the active form's record ID as a filter condition when opening the report.
Ensure you know the exact name of the report you want to open and the primary key field name (e.g., 'ID') used in your form's underlying record source.
Use VBA to Pass a WhereCondition Filter
The most efficient and scalable method is to add a command button that uses the DoCmd.OpenReport method, passing the current record's ID as a filter string (WhereCondition).
By applying a WhereCondition directly via VBA, you avoid hardcoding form references into the report's RecordSource query. This allows the exact same report to be opened seamlessly from any number of different forms.
Open your Microsoft Access form in Design View. Drag and drop a new Command Button from the Form Design toolbar onto your form.
Select the newly created button, press F4 to open the Property Sheet, navigate to the 'Event' tab, and click the builder button (...) next to 'On Click'. Choose 'Code Builder' to open the VBA Editor.
In the VBA editor, construct the filter string using the current form's ID. Type the following code, replacing 'RPTClientDetails' with your report name: Dim strFilter As String strFilter = "[ID] = " & Me!ID DoCmd.OpenReport "RPTClientDetails", acViewPreview, , strFilter
To ensure any unsaved changes on the form are reflected in the report, add 'DoCmd.RunCommand acCmdSaveRecord' immediately before your filter variable declaration.

Email the Filtered Report as a PDF
If you need to distribute the filtered record instead of printing it, you can utilize DoCmd.SendObject to instantly attach the filtered report to an email as a PDF document.
A Lightweight and Free Alternative for Your Daily Office Needs
While Microsoft Access is a specialized tool for complex database management, WPS Office is the perfect free alternative for your everyday document, spreadsheet, and presentation tasks. Enjoy a familiar interface and seamless compatibility with Microsoft Office file formats without hefty subscription fees.
- 1. Download WPS Office: Visit the official WPS Office website and download the free installer for your Windows, Mac, or Linux operating system.
- 2. Install the Suite: Run the downloaded setup file and follow the simple on-screen instructions to complete the installation in just a few minutes.
- 3. Start Creating: Launch WPS Office to instantly view, edit, and create Word, Excel, and PowerPoint compatible files seamlessly.

Frequently Asked Questions
Why does my report display all records instead of the current one?
This usually happens if the WhereCondition (the filter string) in your DoCmd.OpenReport command is missing, empty, or incorrectly referencing the primary key field. Ensure your code specifically states `strFilter = "[ID] = " & Me!ID` and that `strFilter` is passed as the fourth argument in the command.
Do I need to save the current record before clicking the print button?
Yes. Access reports pull data directly from the underlying tables, not the form interface. If you have unsaved data entry on the form, it won't appear on the report. Use `DoCmd.RunCommand acCmdSaveRecord` in your VBA code before the OpenReport command.
Can I filter a report based on a form value without using VBA?
Yes, you can add a criteria directly to the report's underlying RecordSource query (e.g., `[Forms]![YourFormName]![ID]`). However, this hardcodes the report to a specific form, making it impossible to reuse the exact same report across multiple different forms without VBA.




