Hi all,
Please let me know how to catch the "exit" (x button in the top-right corner) so that I can ask whether or not user wants to quit.
Thank you.
Printable View
Hi all,
Please let me know how to catch the "exit" (x button in the top-right corner) so that I can ask whether or not user wants to quit.
Thank you.
In the form's query unload event:
if UnloadMode <> vbFormCode the
'Ask the user.
'if the user responds that he doesn't want to quit:
Cancel = true
end if
Write the folloing code on form unload event :
private Sub Form_Unload(Cancel as Integer)
Dim iChoice as Integer
iChoice = MsgBox("Are you sure ? ", vbYesNo, "Exit")
If iChoice = vbNo then
Cancel = true
End If
End Sub