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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Allow 'Close Form' command before validations

Status
Not open for further replies.

lorirobn

MIS
Mar 15, 2005
450
US
Hello,

I have a form with one combo box, several command buttons, plus a 'Close' command button. I validate the data in this combo box in VBA. I want the user to be able to close (exit) the form before selecting a value. But the validations are done first, and when I click on 'close', I get my data errors. How can I process the Close event PRIOR TO the other events? Is there a way to set the sequence?

Thank you,
Lori
 
I don't think you can. I'd need to know a little more about the logic of your validation, as it seems to be sorta at cross-purposes. I suppose you could implement a MsgBox in your validation to prompt the user whether they really want to close without making a selection in the combo. Or simply exclude the combo from the validation check.

Ken S.
 
Hi Ken,
The form I referenced is a 'Menu'. User selects a room number from combo box, and then clicks on a command button corresponding to the next form he would like to see (data entry details for the selected room). I validate that the room is not null, and that it is an item on the cbo list (with NotInList event). If user enters form, and immediately wants to get out, it won't let him out because cbo is empty. It's annoying!

Not sure what you meant by 'at cross purposes'. Am I mixing things up on the form? Still a novice.

Thanks for your help.
Lori
 
Hi, Lori,

Thanks for the clarification, I now understand why you would want to allow the user out of the form without an entry in the combo.

Where are you validating the data? Sounds like you may have it in the form's Close event. Try putting it in the command button's Click event instead.

Ken S.
 
Hi Ken,

The data for the combo box is validated in the NotInList event for the combo. Processing goes here before it goes to the Close command button.

I fixed another problem thanks to your response. I had had another validation in the cbo's exit, but moved it to the command button's click instead, and it works fine.

It's not a big deal if I don't figure this out... I just like having my form working as clean as possible. Also want to better understand the sequence processing of Access/VBA, and how to possibly control it. (former COBOL programmer, moving to the 21st century).

Thanks a lot,
Lori
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top