Click to See Complete Forum and Search --> : How to chatch "exit" button?


Nikhil V.
October 19th, 1999, 10:21 AM
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.

czimmerman
October 19th, 1999, 11:11 AM
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

Anand Patwardhan
October 19th, 1999, 11:12 AM
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