Load, Unload Events

Applies To

Form.

Description

These events occur:

Remarks

The Unload event is caused by user actions such as:

By running a macro or executing an event procedure when a form’s Unload event occurs, you can verify that the form should be unloaded or specify actions that should take place when the form is unloaded. You can also open another form or display a dialog box requesting the user’s name to make a log entry indicating who used the form.

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

Open Load Resize Activate

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.

Note When you create macros or event procedures for events related to the Load event, such as Activate and GotFocus, be sure that they don’t conflict (for example, make sure you don’t cause something to happen in one macro or procedure that is canceled in another) and that they don’t cause cascading events.

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

See Also

Activate, Deactivate Events; Close Action; Current Event; GotFocus, LostFocus Events; GoToRecord Action; Open, Close Events; OpenForm Action; Resize Event; SetFocus Method.