How to tell if Close Button was clicked

M

Mymind

On my form I have a control that has an edit check on the "Exit" event. If
the control is null or empty, the user is given a warning message.

I would like to have the warning message not appear if the user has clicked
the "Close Button" (red x) on the form.

How can you tell if the user has clicked the forms (window) close button?
 
O

OldPro

On my form I have a control that has an edit check on the "Exit" event. If
the control is null or empty, the user is given a warning message.

I would like to have the warning message not appear if the user has clicked
the "Close Button" (red x) on the form.

How can you tell if the user has clicked the forms (window) close button?

Use a boolean variable that is turned to true if the user clicks an
Exit or Save button. If the variable = false, then the user must have
clicked the close button.
 
K

Klatuu

OldPro gave you most of the information, but as to where, put the code to
check the variable in the form's Unload event. If you determine you don't
want the form to close, you can use the Cancel argument.

Cancel = True
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top