Fix Microsoft Access VBA Module Errors and Database Corruption
Question details
Recover an Access database that displays an error when a query is opened and may have damaged VBA modules.

- Product
- Microsoft Access
- Device & OS
- not provided
- Scenario
- A user opens an Access query and needs to recover the database and its VBA modules.
- Observed behavior
- An error appears when the query opens and cannot be canceled. Database or VBA module corruption is a possible cause, but it has not been confirmed.
Close Access and ask other users to close the database. Locate the affected database file and a recent backup that was known to work before the error appeared.
Restore a Known-Good Access Database Backup
Use this option first if you have a recent backup from before the error began.
Open the folder or backup service where you store Access database backups and find a recent copy that was known to work.
Copy the backup to a separate folder rather than overwriting the affected database.
Open the restored file in Access, run the affected query, and check that the required VBA modules are present.

Compact and Repair a Copy of the Database
Try Access's built-in repair tool if a usable backup is unavailable.
Import Recoverable Objects Into a New Access Database
Try this when a database copy can be read but still has errors after repair.
Work With Exported Access Data in WPS Spreadsheets
WPS Office is a free, lightweight Office alternative with a familiar interface and compatibility with Microsoft Office formats. Export Access tables or query results to Excel to continue working with the data in WPS Spreadsheets. WPS does not repair Access databases or replace Access VBA modules.

Frequently Asked Questions
Does a query error always mean my Access database is corrupt?
No. An error can also have another cause, such as a problem with the query or its dependencies. Test a known-good backup and inspect the affected query before concluding that the database is corrupt.
Can Compact and Repair recover damaged VBA modules?
It may repair some database problems, but it does not guarantee recovery of damaged VBA modules. Run Database Tools > Compact and Repair Database on a copy, then inspect and test the modules.
What should I do if the database will not open?
Close Access, make a copy of the file, and use Compact and Repair Database to select that copy. If repair fails, try restoring a known-good backup or seek specialist recovery assistance.
Can WPS Office repair an Access database?
No. WPS Office does not repair Access databases or their VBA modules. If Access can still export your data, use its Excel export option and open the resulting XLSX file in WPS Spreadsheets.




