Unload

This event occurs when a form is unloading.

Syntax

Private Sub form_Unload(cancel)

Parameters

form
Object expression that evaluates to a Form object.
cancel
Integer. Setting this parameter to any value other than 0 stops the form and application from closing.

Remarks

The QueryUnload event occurs in all forms before any are unloaded, and the Unload event occurs as each form is unloaded.

If you use App.End to terminate an application, forms do not execute the QueryUnload and Unload events.