Cancel form close

S

Snowsride

I am trying to use the On Close event to display a message asking the user if
the really wants to exit. My MsgBox has vbYesNo, with the Yes clicked the
form closes, when the No is clicked I want to cancel the form close action
and leave the form open. Tried Cancel and other permutations without success.

Any ideas?

Thanks
 
B

Brendan Reynolds

You need the Unload event instead of the Close event. The Unload event has a
Cancel argument, set it to True to keep the form open.
 
S

Snowsride

Brendan

Spot on!

Thanks

Brendan Reynolds said:
You need the Unload event instead of the Close event. The Unload event has a
Cancel argument, set it to True to keep the form open.
 
Top