Others

Fix Microsoft Access OutputTo Errors When Exporting Reports and Queries

Phi Hung VoPhi Hung Vo Nov 27, 2026 868 views

Question details

Resolve an Access OutputTo error when exporting a report to PDF or a query to Excel.

Fix Access OutputTo Errors When Exporting Reports and Queries
Product
Microsoft Access 2010
Device & OS
not provided
Scenario
VBA code launched from a form exports a report and a query after running other queries. The code worked in Access 2007.
Observed behavior
Access 2010 reports that the command or action is not available when OutputTo runs. The query export can fail even when the PDF export is disabled.
Before you start

Confirm the report and select query names in the Access Navigation Pane, and make sure the destination folder exists and is writable. Enable database content if Access displays a security warning that prevents VBA from running.

Solution 1Recommended

Open the report and query before exporting them

Use this approach when OutputTo fails because the objects are not open when the export runs.

Opening the select query before OutputTo resolved the reported query export issue. Open the report as well if you are exporting it to PDF, then close both objects after their exports.

1
Open the VBA procedure

In Access, press Alt+F11 and locate the form button's Click procedure or the module that runs the exports.

2
Open and export the report

Before the report export, add DoCmd.OpenReport "ReportName", acViewPreview. Then call DoCmd.OutputTo acOutputReport, "ReportName", acFormatPDF, "C:\Exports\Report.pdf" and close it with DoCmd.Close acReport, "ReportName".

3
Open and export the query

Before the query export, add DoCmd.OpenQuery "QueryName". Then call DoCmd.OutputTo acOutputQuery, "QueryName", acFormatXLSX, "C:\Exports\Query.xlsx" and close it with DoCmd.Close acQuery, "QueryName".

4
Replace names and test

Replace ReportName, QueryName, and the example paths with your actual object names and existing destination paths. Run the button or procedure and check both output files.

Open the report and query before exporting them
Check the execution context: If the code closes the form that contains the button procedure before exporting, test whether execution reaches the export lines. Move the export logic to a standard module or run it before closing the form if needed.
Free Microsoft Office alternative

Work with exported Access query results in WPS Spreadsheets

WPS Office is a free, lightweight alternative with a familiar interface for working with exported spreadsheet files. Open an Excel export in WPS Spreadsheets to continue your work, though WPS does not fix Access VBA or run Access database exports.

Review and edit exported query results in a spreadsheetCompatible with Microsoft Excel XLSX and XLS filesFamiliar spreadsheet interface for an easier transitionFree and lightweight office suite
microsoft office alternative - wps office

Frequently Asked Questions

Why does the query export fail even when the PDF export is disabled?

The query export may have its own issue. Open the select query with DoCmd.OpenQuery before calling DoCmd.OutputTo, and test that export separately.

Do I need to create the export folder first?

Yes. Verify that the folder specified in each OutputTo path already exists and that you can write files to it.

Can closing the form affect the export procedure?

It can affect the code's execution context. Set a breakpoint on the OutputTo line in the VBA editor to confirm it is reached, and consider running the export before closing the form or moving the logic to a standard module.

Can WPS Office run the Access OutputTo command?

No. OutputTo is a Microsoft Access VBA command. After exporting the query to an Excel file in Access, you can open that file in WPS Spreadsheets.