OnLoad -versus- OnOpen

MsLady

Traumatized by Access
Local time
Today, 06:56
Joined
Jun 14, 2004
Messages
438
Please don't beat me up, i simply don't know and coudln't find anywhere with a clear explanation.

Can someone explain the difference between OnLoad event and OnOpen. They seem to perform the same function. No?
 
don't feel bad...I've never seen a clear cut definition either. In my experience, you can have a form open (design view, normal view) and switching between the views does not trigger the open event. The on load event triggers not only when opening the form but when switching views as well.
 
Thanks Bodisathva,
um i don't think i quite get it...:o
 
Consider the order events falls in when opening/closing form:

OnOpen -> OnLoad -> Activate (I think) -> OnCurrent -> DeActivate -> OnUnLoad -> OnClose

Now, because of the ordering, you can cancel a OnOpen load, but not Load (as it's already open), and you can cancel a UnLoad (because it's not removed from screen just yet) but not the OnClose.

Open and Close events has to do with "loading" the forms into the memory but they are not quite on the screen.

Load/Unload event is when forms actually shows on the screen.

Activate/Deactive is when forms has focus or lost focus.

I hope that helps.
 
WOW! thanks for the brilliant explanation. That's the clearest explanation i've seen. I like how you break it down.
definately helps :cool:

Thanks too Bodisathva!!
icon14.gif


I've printed this thread and glued it to my wall. I need to know what im doing OnLoading and OnOpening in this project im working on :D


thankx
thankyou.gif
 
There is another important point. The Open event takes place before the form's recordset is loaded so you can't use any data at that point. The Load event fires after the recordset is loaded.

There is a helpful help entry called something like "find out when events occur" which breaks down to "order of events for controls on forms", "order of events for records on forms", "order of events for keystrokes and mouse clicks", "order of events for reports and report sections".
 
Just key in events to the Access (not VBA) help Answer Wizard.
 
If you are keeping a form open and use the "navigator" buttons, you fire the OnCurrent event but not the OnLoad event.

If you perform an Update on-form and have a way to store the record, when the record has been stored, you do an OnCurrent event when you have finished the update and do the implied "Refresh" of the form.

I think of this way. If the form is a photgraphic plae and the data is the image, you fire an OnLoad when you load a plate into the camera and an OnCurrent when you trip the shutter.

Or - you do OnLoad when you build the blank form with all controls in place but still empty; you do OnCurrent when you populate it. Or REpopulate it.
 
Very niceee!! Thanks guys. I appreciate all your help.

@Pat: Thanks. I found it here: http://msdn.microsoft.com/library/d...ff2000/html/acconOrderEventsRecordsFormsS.asp
Google is my friend :p great resource.

@RG: amaXing, i checked out too. never thought to search in access right under my nose.lol i was looking at a vba book

@ Doc: thanks for that further breakdown. You rock!

I've gotten more broken down explanation here all the same.
*printing again

Thanks all: feel free to add more if you have anything you would like to remind me. more knowledge more power!
icon14.gif
 
Pat Hartman said:
There is another important point. The Open event takes place before the form's recordset is loaded so you can't use any data at that point. The Load event fires after the recordset is loaded.
The_Doc_Man said:
If you perform an Update on-form and have a way to store the record, when the record has been stored, you do an OnCurrent event when you have finished the update and do the implied "Refresh" of the form.
Banana said:
OnOpen -> OnLoad -> Activate (I think) -> OnCurrent -> DeActivate -> OnUnLoad -> OnClose

Okay, my lesson:

So onCurrent is what i will always use in loading my recordset...
 
MsLady,

So onCurrent is what i will always use in loading my recordset...
I hope you just stated it wrong. OnCurrent *happens* when your form loads a RecordSet or changes records. *You* don't use it to load RecordSets; at least not normally.
 
The current event should be used for code that you want to run each time the current record changes. Things that fall into this category are color changes that emphasize control values and requeries for cascading combos
 
Hey! Rural guy..im not that slow :mad:...well maybe jus a little :p but I know it's an event
here's what i was talking about using..:D
Code:
Private Sub Form_Current()
End Sub

yea, what Pat said!

THANKS GUYS!!
 
Awesome; thanks for the link.

Just to be sure, though, I think the Resize event (and maybe Activate/Deactivate event, too) can fire at any other time (e.g. when it get resized or when the focus goes to another form... but not if the focus goes to another application for Activation)
 

Users who are viewing this thread

Back
Top Bottom