How to Split Microsoft Access Reports into Separate PDF Invoices
Question details
The user needs to export a Microsoft Access report into multiple, separate PDF files (one for each invoice) instead of generating a single, continuous PDF document containing all records.

- Product
- Microsoft Access
- Device & OS
- not provided
- Scenario
- Exporting multiple invoice records to distinct PDF files programmatically using a VBA loop in Access.
- Observed behavior
- The current VBA loop exports the entire, unbroken report repeatedly under different filenames because the report's underlying record source is not filtered for each loop iteration.
Ensure you have a basic understanding of Visual Basic for Applications (VBA) and have created a backup copy of your Access database before modifying any queries or VBA modules.
Filter the Report Record Source Using a Hidden Form Control
The most reliable method is to restrict the report's underlying query to a single invoice number using a WHERE clause that references a form control during each loop iteration.
To prevent Access from exporting all records into one file, the report's RecordSource must be filtered to one specific invoice at a time before the export command is executed.
Add a hidden form control (for example, a text box named 'txtInvoiceList' on 'frmInvoicesDlg') to hold the current invoice number during the loop.
Update your report's underlying query to include a WHERE clause that points to this control, such as: WHERE [InvoiceNumber] = [Forms]![frmInvoicesDlg]![txtInvoiceList].
In your VBA code, set the hidden form control to the current invoice number before executing the output. For example: Forms!frmInvoicesDlg!txtInvoiceList = rs!InvoiceNumber.
Use DoCmd.OpenReport in hidden mode, followed by DoCmd.OutputTo to export the filtered report to a specific PDF path, and then call DoCmd.Close before the loop moves to the next record.

Pass Filter Parameters Directly in the OpenReport Command
An alternative approach is passing a WHERE condition string directly when opening the report via VBA, avoiding the need to modify the underlying query structure.
Discover a Lightweight Alternative to Microsoft Office
While Microsoft Access handles complex database reporting, WPS Office provides a free, lightweight, and robust suite for all your document, spreadsheet, and PDF management needs. It features a highly familiar interface and built-in PDF tools for seamlessly handling your exported reports.
- 1. Download the Installer: Visit the official WPS Office website and download the free installation package for your operating system.
- 2. Install WPS Office: Run the downloaded file and follow the straightforward on-screen instructions to set up the software.
- 3. Manage Your Documents: Launch WPS Office to open, edit, or split your exported PDF reports and Office documents effortlessly.

Frequently Asked Questions
Why does my VBA loop export the entire database into every PDF?
The DoCmd.OutputTo action exports the report exactly as it is defined in its RecordSource. If the report's query isn't dynamically filtered to a single record during the loop iteration, Access will continuously export the full, unbroken report.
Can I split the invoices after exporting them as one large PDF?
Yes, if the report has already been exported as a single long PDF, you can use dedicated PDF editing software, such as the WPS Office PDF toolkit, to manually extract or split the pages into separate documents.
How do I hide the Access report while exporting it to PDF?
You can use the 'acHidden' constant as the WindowMode argument in the DoCmd.OpenReport method. This processes the report in the background without visibly rendering it on your screen, speeding up the PDF export process.




