Click to See Complete Forum and Search --> : Halt QueryUnload Event


dodgly
May 20th, 2001, 02:21 AM
During the QueryUnload event I want to *stop* VB from shutting down the program.

For example. The user clicks the corner 'X'. During the QueryUnload event I prompt the user with a YesNoCancel MsgBox. If the user hit's cancel I need to stop the QueryUnload event from actually shutting down the application.

Any thoughts on how I can do this?

--Lyle E. Dodge
lyle@lyledodge.com

Rob@SYPTE
May 20th, 2001, 05:14 AM
Try this:

Dim strReply As String

strReply = MsgBox("End?", vbYesNo)

If strReply = vbNo Then 'User clicks no
Cancel = True 'Dont end program
Else
Cancel = False 'End Program
End If

Cheers

Rob

dodgly
May 20th, 2001, 02:49 PM
Rob,

Beautiful! Thanks so much. I've been coding for years and figured I could nail this one so I was getting frustrated.

In fact I was using Cancel = True elsewhere in the QueryUnload event but I was turning it False based on other conditions but I didn't realize that would affect the Event stopping or not.

Anyhow. I *really* appreciate your tips. Worked perfectly, as you expected.

--Lyle E. Dodge
lyle@lyledodge.com