Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Difference between 'on load' and 'on open' 2

Status
Not open for further replies.

ajaeger

Technical User
Joined
Feb 6, 2003
Messages
201
Location
US
What is the difference between the 'on load' and the 'on open' event of a form? This may not even be the right direction to take to solve my issue:

I have a frmMainMenu and I want to run a bit of code when the database is first opened (it opens to this form). I initially put the code on the 'on open' event, but then at any point, when the user clicks on any of the "Go To Main Menu" command buttons that I have in other places in the database, the code runs again.

Is there a better way to do this?

Anna Jaeger
iMIS Database Support
 
One of the "tricks" I use, is keeping the main menu/form open, but hide it when opening the next form. Then set it visible again in stead of opening it when returning.

You could probably also use a public variable which you toggle after the code is run the first time, then check against it later.

Roy-Vidar
 
The On_Load event only runs when the form is first loaded, and after any records (If any!) are shown, whereas the On_Open event runs when the form is first opened, before any records are shown.

I agree with RoyVidar, in that the best way would be to hide your main form instead of closing it. This way, the On_Load event will only fire the first time the DB is opened, and not every time it is returned too...

=)
 
OK, on frmMainMenu, I've replaced DoCmd.Close with form.Visible = False and then opened the sub form that I need to navigate too.

Now, on the sub form, where before I had DoCmd.Close to close that form and then DoCmd.Open to open frmMainMenu, how do I write form.Visible = True to specify the specific form that I want to make visible?

Thanks.

Anna Jaeger
iMIS Database Support
 
Something along the lines of the following two statements, I think

[tt]me.visible = false

forms("frmNameOfYourform").visible=true[/tt]

Roy-Vidar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top