Startup code location ...

Local time
Yesterday, 20:32
Joined
Feb 28, 2023
Messages
696
I have code in my database that checks for the startup location and checks for an updated version and then downloads the version.

I was looking at @isladogs autoexec page https://www.isladogs.co.uk/autoexec-myths/index.html on a different issue: https://www.access-programmers.co.u...-or-action-onerror-isnt-available-now.328585/

And I noticed this statement:
1. Autoexec runs first before any other code
WRONG – code in the startup form runs followed by any actions from the autoexec macro

My previous version of the database loaded FormA on startup and ran this code from the FormLoad Event of FormA.

With the new version of the database, I went to a switchboard form, but I moved this code to a module function which is called from the AutoExec VBA code and then the VBA Code loads the switchboard form. No form is specifically loaded at startup.

Should I change it back (i.e. should I load the switchboard form at startup and run the checks from there), or does it not matter?
 
The only time that it matters is if you have both an AutoExec macro AND a Startup form with an active OnOpen or OnLoad sequence. Decide which one you want to run and do everything there, dropping the other like it was a hot potato.

Now, having said that, I always run in a startup form's event context for startup code because of better control over errors than you have for macros. If you wanted to do anything fancy from a macro, you would have to trigger a RunCode action anyway.
 
Personally, I think it's just a matter of preference.
 
Oddly enough, I selected the frm_Switchboard form to load at startup and moved some of the code there and it fixed the OnError Error that I was receiving.
The only time that it matters is if you have both an AutoExec macro AND a Startup form with an active OnOpen or OnLoad sequence. Decide which one you want to run and do everything there, dropping the other like it was a hot potato.
Actually, the current and the prior procedure did have both an AutoExec macro and a Startup form.

I think I'll take your advice and kill the autoexec macro.
 

Users who are viewing this thread

Back
Top Bottom