Well in your case you should use the QueryUnload event since you only want to hide the form if someone clicks the X button. But if someone is shuting down Windows or you want to end the application through code you want to unload the form so your application ends properly. You can only test why your form is being unloaded in the QueryUnload event.VB Code:
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer) If UnloadMode = vbFormControlMenu Then 'the X has been clicked or the user has pressed Alt+F4 Cancel = True Me.Hide End If End Sub




Reply With Quote