You cannot selectively enforce when the Exit event occurs and when it does
not. If you put code in the Exit event procedure that refuses to let the
person leave the control unless the user selects something, then that is
what happens -- no matter the reason why the user wants to leave the
control.
So either you require the user to select something just so that the user
then can click the Cancel button, or you do not require the user to select
anything in the combobox at all -- at least not via the Exit event.
How do you "trigger" the running of the query that uses the form's combobox?
If by a button on the form, use that button's Click event to do your
validity check. Or, if no selection in the combobox can be interpreted as
"return all records unfiltered", change the criterion (WHERE clause) in your
query to handle this:
FieldName = Forms!NameOfForm!cbFacility OR Forms!NameOfForm!cbFacility IS
NULL
--
Ken Snell
<MS ACCESS MVP>
http://www.accessmvp.com/KDSnell/
Thanks, Ken. I'm not sure I follow. And perhaps I wasn't clear.
I don't want to force the user to select a value. I want them to be
able to exit "cbFacility" IF and ONLY if they're trying to click the
cancel button.
The form is used to filter a query. cbFacility needs a selection in
order to requery other controls however if a user opens the form and
then decides to cancel they get the exit error msgbox which can create
confusion as if they've done something wrong and MUST run the query.
Is this how you understood it and am I misunderstanding your response?
Thanks!