Fix Microsoft Access Printing Main Form Instead of Current Report
Question details
The user needs to prevent Microsoft Access from printing or emailing the main form when they intend to output the current report for a specific active record.

- Product
- Microsoft Access
- Device & OS
- not provided
- Scenario
- Printing or emailing a specific report, such as a donation form or tax receipt, from an active database form.
- Observed behavior
- Microsoft Access prints, opens, or emails the main form or an unfiltered report instead of the intended report for the current record.
Before modifying your event macros, identify the exact primary key field (e.g., DonorID or InvoiceID) on your active form, as you will need this to construct the correct WhereCondition.
Use WhereCondition to Filter the Current Report in VBA
Apply a WhereCondition to the DoCmd.OpenReport or DoCmd.SendObject command to ensure only the current record is processed.
When an Access form triggers a report without specific filtering instructions, it defaults to printing the active object (the form itself) or the entire unfiltered report. Explicitly passing a WhereCondition restricts the output to the active record.
Launch your Access database, right-click the main form containing your print or email button, and select 'Design View'.
Right-click the specific Print or Email button, select 'Build Event' from the context menu, and choose 'Code Builder' to open the VBA editor.
Locate your `DoCmd.OpenReport` or `DoCmd.SendObject` line. Add a WhereCondition parameter that links the report's ID to the current form's ID, formatted like: `DoCmd.OpenReport "rptTaxReceipt", acViewPreview, , "[DonorID]=" & Me.DonorID`.
Save the VBA code, return to Form View, and click the button to verify that only the receipt for the currently selected donor is generated.

Verify the Report's Record Source Property
Ensure the report itself is bound to the correct underlying query or table and is designed to accept filters.
Dynamically Pull Email Addresses from Form Controls
Ensure the correct recipient receives the report by referencing the active form's email control instead of hard-coding the address.
Manage Invoices and Receipts Easily with WPS Office
Dealing with complex VBA macros and Access databases can be frustrating when you simply need to generate and print invoices or tax receipts. WPS Office provides a free, lightweight, and highly compatible alternative. You can easily organize your data and automate professional invoices using WPS Spreadsheet without any complicated programming.

Frequently Asked Questions
Why does DoCmd.SendObject attach the main form instead of my report?
This typically occurs if the report name is incorrectly specified in the command parameters or left blank, causing Access to default to outputting the currently active object, which is the form you clicked the button on.
How do I filter a report without using VBA code?
You can use Access Macros instead of VBA. Open the Macro Builder, use the 'OpenReport' action, and set the 'Where Condition' argument to something like `=[DonorID]=[Forms]![YourFormName]![DonorID]`.
Can I use WPS Office to open Microsoft Access (.accdb) database files?
No, WPS Office is an office suite featuring Writer, Spreadsheet, Presentation, and PDF tools; it does not include a direct relational database application like Access. However, you can export your Access tables to Excel (.xlsx) format and easily open and manage them in WPS Spreadsheet.




