Troubleshoot Microsoft Access Closing During OutputTo PDF Export
Question details
The user needs to determine why a Microsoft Access database closes during a startup report-to-PDF export and prevent it from closing before subsequent code runs.

- Product
- Microsoft Access
- Device & OS
- Windows 10; exact Windows and Microsoft Access versions not provided
- Scenario
- A startup form's On Load event calls OutputTo to export a report as a PDF with a specific OutputFile path. Behavior may differ when the database is launched manually or through Task Scheduler.
- Observed behavior
- The database closes before later code executes on some computers, while the same workflow completes successfully on the client's computer.
Record the exact OutputFile path, Access version, Windows build, and launch method on an affected computer and a working computer. Confirm whether only the database closes or the entire Access application exits.
Isolate the OutputTo call and test the destination path
Use a minimal manual test to determine whether the export call or its destination triggers the closure.
The reported behavior does not establish a single confirmed cause. Simplifying the startup code and changing only one variable at a time helps distinguish a path problem from an event or environment issue.
Open the database while holding Shift to bypass startup actions, if bypass is enabled. Open the startup form in Design View, select Property Sheet > Event > On Load, and use the build button to inspect its event procedure.
Press Alt+F11 to open the VBA editor. Copy the report's OutputTo call into a separate test procedure, keeping the same report name and PDF format. Remove unrelated operations from the test and run it manually from the editor.
Create a folder through File Explorer in a location where your account can create files. Change the test procedure's OutputFile argument to a full local filename ending in .pdf, and run the test again.
In File Explorer, open the original destination folder and try creating a file there. Verify that the folder exists and that an existing output PDF is not open or locked, then restore the original OutputFile path and repeat the export.
In the VBA editor, set a breakpoint on the line immediately after OutputTo by clicking its left margin. Run the test and check whether that breakpoint is reached and whether the PDF was created.

Compare manual startup with Task Scheduler execution
Use this comparison when the export behaves differently depending on how Access is launched.
Compare affected and working systems before deployment
Use version and crash information to investigate a problem that reproduces only on certain computers.
Use WPS Office for Everyday Documents and PDF Export
WPS Office is a free, lightweight alternative for document, spreadsheet, and presentation work, with a familiar interface and Microsoft Office format compatibility for a smooth transition. It can export supported documents to PDF, but it does not run Access databases or fix Access OutputTo automation.

Frequently Asked Questions
Why does Access close only when I specify an OutputFile path?
The path may expose a permissions, file-locking, or network-access issue, but the reported behavior does not prove a single cause. In the VBA editor, test the same OutputTo call with a full filename in a writable local folder, then compare it with the original destination.
How can I tell whether OutputTo finishes before Access closes?
Press Alt+F11 and set a breakpoint on the line immediately after the OutputTo call. Run the export and check whether execution reaches that line. Also check the output folder for the PDF; file creation alone does not prove that subsequent code ran.
Why might the export work manually but fail in Task Scheduler?
A scheduled task may run under a different account or session and may not have the same network access or mapped drives. Open Task Scheduler > Task Scheduler Library > the task's Properties and review General, Actions, and Settings, including the run account, launch arguments, and stop conditions.
Does this mean newer Access or Windows versions have a PDF export bug?
Not necessarily. The issue was reported on some systems but not others, without a confirmed version-specific cause. Compare About Access and winver information, run the same minimal export on each system, and check Event Viewer if Access exits unexpectedly.
Can WPS Office replace this Access report automation?
No. WPS Office does not run Access .accdb or .mdb databases or their VBA report automation. For supported documents, spreadsheets, and presentations, you can use WPS Office's PDF export options, but the Access workflow still requires separate troubleshooting.




