Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Close a form with vbCancel

Status
Not open for further replies.

wizcow

Programmer
May 11, 2002
13
CA
Hi

If certain text boxes are left blank on my form, I want a msg box to alert the user.
If the user clicks vbRetry, on the msg box, they will be taken back to the empty text box. (I have this part working.)

What I can't get to work is this part;
If the user clicks vbCancel, on the msg box, then I want the msg box and the form to close, without saving the file.

Any ideas why my form won't close.
Tom
 
You need to undo the changes on the form before it will close. You might think that discarding the changes was obvious, but if Access is already into its update process, it won't allow you to throw away unsaved changes except by doing an explicit Undo. Use the Form.Undo method. I think the close will be accepted then.

As an alternative, you could just let the MsgBox inform them of the problem, and have just an OK button that returns them to the text box. Then they can choose to correct the problem or to click Edit|Undo and then close the form. Rick Sprague
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top