This event occurs immediately before a form or application closes.
Private Sub Form_QueryUnload(cancel, unloadmode)
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.