How do I bypass the MSAccess autoexec macro and startup form for a deep-legacy code upgrade of a large MS Access 2003 application with hundreds of forms and reports?
It is an upgrade from Access 2003 to Access 2016, 2019 or 365.
This is a mission critical system kept alive and on crutches for 15 years without any VBA code updates.
- Files in the application
- Multiple MSAccess files in MDB and ACCDB format
- No MSAccess files in MDE or ACCDE formats with compiled VBA code
- No MSAccess other files wuch as mdw security files
- I run a dos command for the database - PATH_TO_MSACCESS.exe DB_NAME.mdb
- I'm using MSAccess.exe 32 bit from Office 365.
- Note that there are compatibility and VBA compiler errors if you run on a 64 bit MSAccess.exe if the VBA calls Windows operating system Win32 API methods. This app calls a few (5) Win32 API calls. Technical, MS Access 64 bit will treat some 32 bit data sent in/returned from the Win32 API as 64 bit causing errors.
The most difficult part is that many of the web pages and nearly all Microsoft pages related to this have been deleted from the web.
- Tried but did not work
- Holding down shift key when you open the MSAccess database
- Hitting F11 to open the Navigation Pane in Access (does not open). If Navigation Pane opens I could edit the AutoExec macro or the startup form's Form_Open code
- Tried, not perfect, and works
- Run a macro which does not exist on MSAccess.exe command line, hit escape multiple times on the error messages, the click on the MSAccess ribbon to get to the VBA code. Messy, but it gets me into the VBA code.
- Added a "Stop" as the first line of the macro named "autoexec" and also as the first line of the startup form's "Form_Open()" method. I had to add an empty "Form_Open()" event handler for the form
- Run a macro which does not exist on MSAccess.exe command line, hit escape multiple times on the error messages, the click on the MSAccess ribbon to get to the VBA code. Messy, but it gets me into the VBA code.
Current status:
- The application runs OK on a machine with MS Access version before 2016
- It fails multiple ways when only 32 bit MS Access 365/2019 is installed on the machine.
- I have been finding and fixing things like bad configuration file entries, incorrect installation path, etc. but need to debug the VBA startup code and initial form load in the VBA debugger.
- I cannot directly get into the VBA debugger on the first line of the AutoExec macro or start up form's Form_Open function. MSAccess always runs the autoexec macro and shows the startup form.
- I can get into the VBA by running MSaccess.exe command line and specifying that it runs a macro which does not exist.
- I cannot directly get into the VBA debugger on the first line of the AutoExec macro or start up form's Form_Open function. MSAccess always runs the autoexec macro and shows the startup form.
- I have been finding and fixing things like bad configuration file entries, incorrect installation path, etc. but need to debug the VBA startup code and initial form load in the VBA debugger.
Here are possible solutions based on Google searching broken out by Access version since the code/database settings in question could be specific to any Access version from 95 to 2010.
Access 2007: Opening an MS-Access database from the command line without running any of the startup vba code? Hold down shift key when opening MDB database
Access XP Open access database without executing scripts or forms
- Hold down shift key when opening the Access database
- Remove AutoExec macro
- Remove the startup form setting from the database
Access 2007: Emulating a SHIFT key press when using VBA to open an ms-access database secured by an mdw file?
- Slightly different case where the Access database is secured by a MDW security file
- Same answers
Access XP/2003/2007? How to skip Autoexec macro when opening MSAccess from MSAccess?
- Method One:
- Original URL is dead, Internet Archive Wayback machine has an archived copy: https://web.archive.org/web/20101204113950/http://www.mvps.org/access/api/api0068.htm
- Send Shift key to Access via code to bypass startup macro if the [AllowbypassKey] is not set
- Method Two:
- Extract the Autoexec macro from the database, replace it with a blank AutoExec macro
- Uses DoCmd.DatabaseTransfer acImport and DoCmd.DatabaseTransfer acExport
- Method Three:
- Rename the AutoExec macro using VBA code
- OpenCurrentDatabase ("Your database")
- DoCmd.Rename "Autoexec", acMacro, "tmp_Autoexec"
- CloseCurrentDatabase
MS Access keyboard short cuts for getting at the VBA code or objects in an Access database. From https://support.microsoft.com/en-us/office/keyboard-shortcuts-for-access-70a673e4-4f7b-4300-b8e5-3320fa6606e2 I haven't tried the MSAccess keyboard short cuts to see if they let me open and view the Access VBA code, toolbars, table/form dedign viewer, or switch to code editing mode. I've included them here for completeness.
- F2 - Switch between Edit mode (with insertion point displayed) and Navigation mode in the Datasheet or Design view
- F4 - Open properties pane for an object
- F5 - Switch to Form view from the form Design view
- F6 - Switch between panes in the MS Access interface
- F10 (?) unhide the ribbon
- F11 - Show or hide the Navigation Pane
- Alt-X, Alt-X,1 - Open the External Data tab in the ribbon
- Alt-Y - Open the Database Tools tab in the ribbon
- Alt-J,T - Open the Table tab in the ribbon
- Alt-X,2 - Open the Add-ins tab in the ribbon
- Control-F1 - Expand/collapse the ribbon
- Alt-F11 - Switch to/from the VBA editor
Show or hide the MSAccess ribbon toolbar in VBA code. Included here for completeness. This application hides the ribbon bar on application startup. MSAccess - Minimize the Toolbar Ribbon OnLoad()?
- MSAccess 2010 onwards. The acToolbarNo is in the VBA code for this application
- DoCmd.ShowToolbar "Ribbon", acToolbarNo 'Hides the full toolbar
- DoCmd.ShowToolbar "Ribbon", acToolbarYes 'Show
- MSACcess 2010, 2013
- CommandBars.ExecuteMso "MinimizeRibbon"
- Before MSAccess 2010
- SendKeys "^{F1}", False
Special case: You may get an error on the Access startup form if it has a record source which has an error. this is not the case for my application but included here completeness difficulty tracing microsoft access VBA code
Special case: You get an infinite loop of dialog prompts or errors from the startup form. Hold down the "Control-Break" key while clicking on OK for the error message to break out of the loop of errors. https://bettersolutions.com/vba/debugging/index.htm
It may be possible to break out of the main startup form to the MS Access object explorer by right clicking on the startup form's title bar or right click on the startup form's body.
- Right clicking on the startup form's title bar has these menu commands
- Save
- Close and Close All
- Form View
- Layout View
- Design View
- Right clicking on the startup form's body has these menu commands
- Form View
- Layout View
- Design View
- Cut, Copy, Past (disabled)
- Form Properties (disabled)
- Properties (disabled)
- Close