Startup code location ... (1 Viewer)

Local time
Today, 12:04
Joined
Feb 28, 2023
Messages
628
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_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 11:04
Joined
Feb 28, 2001
Messages
27,187
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.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 09:04
Joined
Oct 29, 2018
Messages
21,473
Personally, I think it's just a matter of preference.
 
Local time
Today, 12:04
Joined
Feb 28, 2023
Messages
628
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

Top Bottom