Fix a Microsoft Access Database That Opens and Closes Immediately
Question details
Find out why a Microsoft Access database closes immediately after opening.

- Product
- Microsoft Access
- Device & OS
- not provided
- Scenario
- The user needs to open an Access application and diagnose its startup routine.
- Observed behavior
- The application opens and closes without displaying an error.
Locate the database file and make sure you have permission to open it and inspect its VBA code. The Shift-key bypass may not work if the database administrator has disabled it.
Bypass startup and step through the Access VBA routine
Use this method to identify the statement that triggers the application's shutdown.
Hold Shift while opening the database file in Access, and keep holding it until the database opens. This bypasses startup actions when the Shift-key bypass is enabled.
Press Alt+F11 and locate the startup function, such as ApplicationStart, in the project. Find any error handler that calls DoCmd.Quit or otherwise closes the application.
Place the cursor in the startup function and press F8 to step through it, supplying any required arguments if prompted. Continue through the procedures it calls until you reach the failing statement.
In the VBA editor, use Tools > Options > General and temporarily select Break on All Errors if the error handler hides the failure. Step through the routine again, record the error message, and restore the previous setting afterward.

Inspect the user ID and failing UPDATE statement
Use this method if stepping through startup points to the login UPDATE query.
Use WPS Office for Everyday Documents and Spreadsheets
WPS Office is a free, lightweight alternative for everyday office work, with a familiar interface and Microsoft Office format compatibility for easier migration. It does not repair or run Microsoft Access databases.

Frequently Asked Questions
Why does my Access database close without showing an error?
A startup procedure may encounter an error and call a shutdown command from its error handler. Hold Shift while opening the database, then step through the startup VBA code to find the failing statement.
What if holding Shift does not bypass Access startup?
The database may have the Shift-key bypass disabled. Contact the database administrator for access to the startup code or another way to open the database without running its startup actions.
How can I see the SQL generated by my Access VBA code?
Add Debug.Print strSQL before the execution line, then press Ctrl+G in the VBA editor to view the printed statement in the Immediate window. You can copy it into a new Access query's SQL View for inspection.
Why should I check gs_User_ID before the UPDATE query?
A Null, unexpected, or incorrectly typed user ID can cause the generated UPDATE statement to fail. Pause before the query and inspect gs_User_ID in the VBA editor's Locals or Immediate window.
Can WPS Office fix an Access startup error?
No. The Access database and its VBA startup code must be diagnosed in Microsoft Access. WPS Office can be used separately for compatible documents, spreadsheets, and presentations.




