Open v. Load what's the difference?

U

Undrline

It's a quick question, but what's the difference if I put a line of VBA
script in the Open handler or the Load handler? I assume Load waits for all
the form stuff first? So if I were to do something short - for instance
DoCmd.Close, I'm assuming it would show all the fields, run all the queries,
subforms and so forth and then close, if I put it in Load, and it wouldn't
wait for this if I put it in Open?
 
P

pietlinden

Undrline said:
It's a quick question, but what's the difference if I put a line of VBA
script in the Open handler or the Load handler? I assume Load waits for all
the form stuff first? So if I were to do something short - for instance
DoCmd.Close, I'm assuming it would show all the fields, run all the queries,
subforms and so forth and then close, if I put it in Load, and it wouldn't
wait for this if I put it in Open?

If you poke around in the VBA help file, you'll find some information
on this...

If you're trying to decide whether to use the Open or Load event for
your macro or event procedure, one significant difference is that the
Open event can be canceled, but the Load event can't. For example, if
you're dynamically building a record source for a form in an event
procedure for the form's Open event, you can cancel opening the form if
there are no records to display.

When you close a form, the following events occur in this order:

Unload Þ Deactivate Þ Close

The Unload event occurs before the Close event. The Unload event can be
canceled, but the Close event can't.
 
U

Undrline

Oh, I forgot to include activate ... thanks. Open v. Load v. Activate is
really the question.

You say it's in the help file? Do you have some keywords you could give me
to find it? Typing in Open or Load didn't really narrow down the search.

Thanks.
 
M

Marshall Barton

Undrline said:
It's a quick question, but what's the difference if I put a line of VBA
script in the Open handler or the Load handler? I assume Load waits for all
the form stuff first? So if I were to do something short - for instance
DoCmd.Close, I'm assuming it would show all the fields, run all the queries,
subforms and so forth and then close, if I put it in Load, and it wouldn't
wait for this if I put it in Open?


If you want to operate on data in the form's record source,
you must wait until the data is loaded. If you want to move
controls around or set the form's record source or control's
ControlSource then use the Open event.
 
D

Douglas J. Steele

Doing a search on any of those 3 terms should result in hits. Remember that
you need to be in the VB Editor when do this, as these are VBA concepts.
 
Top