How to tell if Close Button was clicked

  • Thread starter Thread starter Mymind
  • Start date Start date
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?
 
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.
 
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
 
Back
Top