Question : Access Autoexec macro vs. Form_Open code for default form

This question is just to improve my understanding of Access.

I want a form (frmKeepAwayFromLdb) to open when the database opens and remain open AND HIDDEN throughout. When it opens and hides, it should open my Menu form (frmMain).

I do have this working with the Autoexec macro, but when I put the same code into the Form_Open event of frmKeepAwayFromLdb, that form doesn't hide and it keeps the focus with frmMain open behind it. Can anyone tell me why, please?
Code Snippet:
1:
2:
DoCmd.OpenForm "frmKeepAwayFromLdb", acNormal, "", "", acReadOnly, acHidden
    DoCmd.OpenForm "frmMain", acNormal, "", "", , acNormal

Answer : Access Autoexec macro vs. Form_Open code for default form


<>
  Not any more efficient really, but the biggest disadvantage is no error handling and up until A2007, no structured conditions either (IF statements).

  However for something like this, it's six one way, half a dozen another as in the case, the startup form property for the database could be used in place of an Openform in the autoexec.

  I myself happen to use the auto approach method.  One reason for that is that it's easy for me to turn things on and off in the Autoexcec just by entering FALSE in the condition column.  This is handy when I'm debugging something or don't have the same environment that might exist else where.

  Also, everything I do in the Autoexec doesn't have a corresponding database property/method and I like to see all my startup stuff in one place.  The Autoexec contains all the logic that should execute before any form starts up (even my hidden one).

Of course, you could specify a startup form of "frmStartup" and place code in there to replace the autoexec.  Net result would be the same really.   Only difference is that you now have a form open that needs to be closed.

Overall, using the autoexec just seems cleaner to me, but that's me.

JimD.

 
screen shot
screen shot
 
Random Solutions  
 
programming4us programming4us