You can either use a startup form or an autoexec macro for any code you want to run when your application loads.
Its largely down to personal preference though I generally use a startup form.
Two things to bear in mind.
1. A startup form that is set in Database Options loads before an autoexec macro
2. If you convert your app into an ACCDE, any code in forms is inaccessible to an end user.
However, an end user will still be able to modify or disable an autoexec macro
Thank you Isladogs, I don't like to convert my program, but if possible I would like to see an example of an 'Startup Form', please?You can either use a startup form or an autoexec macro for any code you want to run when your application loads.
Its largely down to personal preference though I generally use a startup form.
Two things to bear in mind.
1. A startup form that is set in Database Options loads before an autoexec macro
2. If you convert your app into an ACCDE, any code in forms is inaccessible to an end user.
However, an end user will still be able to modify or disable an autoexec macro
Regards, Jaap
Any form can be opened automatically when your app loads. To do so, click File...Options...Current Database and enter a form name as shown below
If you want you can add code to the form load event to do whatever else is in your autoexec macro
Do make sure you set Echo true and the hourglass false again afterwards!Code:Private Sub Form_Load() DoCmd.Hourglass, True Application.Echo False End Sub
Remove the .Echo from that line. Your code for that line should be
NOTE In my last post, I wrongly included a comma but I'm no longer able to edit that post to correct itCode:DoCmd.Hourglass True
Thank you isladogs for helping me, now it's working without a warning. :-)
Private Sub Form_Load()
On Error GoTo Fout
DoCmd.Hourglass True
Application.Echo False
Fout:
Exit Sub
End Sub
For me, this Topic is solved.
Regards, Jaap
Dear isLadogs,
I'd like to ask you something, please.
Today I used your Example and explanation to start an Access program without an Autoexec.bat file
After making this Settings, the program is starting correctly without a AutoExec file. :-)
But when I using also this VBA commands in Form SchakelbordF:
Private Sub Form_Load()
On Error GoTo Failure
DoCmd.Hourglass True
Application.Echo False
Failure:
Exit Sub
End Sub
The Access program will not start anymore, the hourglass keeps spinning?
It is necessary to use this VBA commands?
Regards,
Jaap
Last edited by Jaap; 02-26-2023 at 07:12 AM. Reason: Deleted wrong image.
The hourglass will continue to spin until code is used to set it to false.
Similarly screen updating will stay disabled until Application Echo is set to true.
You will see I do both of those in my example
If that is your entire Form_Load code, it is causing your problem and doing nothing useful. Get rid of it.
Dear isladogs, thank you for this reply.
The program works very well with just 'Access Options' and 'Current Database' with the data you sent me.
I also did not program any VBA data into 'Private Sub Form_Load()'.
I also deleted all macros, including the AutoExec file.
I want to ask you if it's good enough now, please?
Regards,
Jaap
The setting of 'Access Options' and 'Current Database' ensures that my computer boots properly to my Switch Form.
So further safety precautions are not necessary at this point.
Thanks isLadogs for the cooperation.
Regards,
Jaap