Troubleshoot Microsoft Access Queries That Do Not Run from VBA
Question details
Identify why Access action queries appear not to run when called from VBA, even though they work when run manually.

- Product
- Microsoft Access
- Device & OS
- not provided
- Scenario
- A VBA procedure runs action queries or SQL statements to populate tables, including an append query.
- Observed behavior
- The queries appear to do nothing from VBA, and warning or error messages may not be visible.
Open the database and identify the VBA procedure and action queries involved. Note the source and destination tables for each statement so you can check them in sequence.
Restore Access warnings and add error handling
Use this approach when VBA runs without displaying the usual action-query warnings or useful error details.
Press Alt+F11 to open the VBA editor, locate the procedure that runs the queries, and search its code for DoCmd.SetWarnings False.
Add DoCmd.SetWarnings True after the statements that require warnings to be disabled. Route both normal completion and errors through a cleanup section that restores warnings.
Add an On Error handler to the procedure and display or log Err.Number and Err.Description before leaving through the cleanup section.
Run the procedure from Access or the VBA editor and check any warning or error message to identify the statement that needs attention.

Check query tables and test each SQL statement
Use this method when an append query runs but adds no records, or when an earlier statement may target the wrong table.
Work with Office documents and spreadsheets in WPS Office
WPS Office is a free, lightweight alternative with a familiar interface for working with Office files. It supports common Microsoft Office formats for an easier transition, but it does not troubleshoot Access or run Access databases and VBA procedures.

Frequently Asked Questions
Why does my Access action query run without a confirmation prompt?
The VBA procedure may have called DoCmd.SetWarnings False. Check the procedure in the VBA editor and restore warnings with DoCmd.SetWarnings True, including in its error cleanup.
Why does an append query add no records?
The source table may be empty, the criteria may match no records, or an earlier statement may have populated the wrong table. Open the source table or run the underlying select query to check the records.
How can I tell which VBA statement is failing?
Add an On Error handler that reports Err.Number and Err.Description. You can also add Debug.Print statements around each query and inspect the Immediate window in the VBA editor.
Can WPS Office run my Access database and VBA queries?
No. Use Microsoft Access to run and troubleshoot Access databases and VBA queries. WPS Office can instead be used for common Office documents and spreadsheets, including XLSX files.




