Form_Close

  • Thread starter Thread starter kenrav
  • Start date Start date
K

kenrav

After the user clicks the red X at the top of a form to close it, I'd like to
ask the user if he/she really wants to exit. I created a VbYesNo question in
the Form_Close event; Yes to continue closing and No to cancel. Question,
what code to put to keep the form from closing (inasmuch as we're already in
the Form_Close event?)
 
kenrav said:
After the user clicks the red X at the top of a form to close it, I'd like to
ask the user if he/she really wants to exit. I created a VbYesNo question in
the Form_Close event; Yes to continue closing and No to cancel. Question,
what code to put to keep the form from closing (inasmuch as we're already in
the Form_Close event?)


Use the form's Unload event with the Cancel argument:

If MsgBox("Close?", vbYesNo) = vbNo Then Cancel = True
 
Back
Top