QueryUnload

This event occurs immediately before a form or application closes.

Syntax

Private Sub Form_QueryUnload(cancel, unloadmode)

Parameters

cancel
Integer. Setting this parameter to any value other than 0 stops the form and application from closing.
unloadmode
Value that indicates the cause of the QueryUnload event. The unloadmode parameter is always 0.

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.