Not In List event flawed?

G

Guest

I have a form with a combo box for selecting customers. The table field is
"required". The combox box has the limit to list property set to YES & the
not in list event is set up to open a form to add a new customer. All works
fine, except that I just recently noticed that if I "tab" past the combo box
without entering anything, the not in list event is NOT triggered & I don't
get notified about the lack of an entry in Cust_ID until focus transfers to a
subform - which occurs after I have entered data in several other controls on
the main form.
I have tried every event I can think of to trap a null entry in the
combo box & can get it to "sort of work", but I would like to be able to
cleanly trap this and keep focus on the combo box until a valid entry is made.
Any help would be greatly appreciated.
Garry Gross
 
G

Guest

You need to validate the required data using the Form's Before Update event ...

R. Hicks
 
G

Guest

Ricky,
checking for IsNull or IsEmpty in the Before Update event does not work.
If I hit Tab or Enter without entering anything, focus "happily" moves on to
the next control. I would like to trap this before focus goes to the next
control.
Garry
 
F

fredg

Ricky,
checking for IsNull or IsEmpty in the Before Update event does not work.
If I hit Tab or Enter without entering anything, focus "happily" moves on to
the next control. I would like to trap this before focus goes to the next
control.
Garry

Does this help?
Code the Combo Box Exit event:
If IsNull(Me![ComboName]) or Me![ComboName] = "" Then
MsgBox "You must enter a value." ' Optional message
Cancel = True
End If
 
G

Guest

fredg,
Thanks, it works. I think it was the
Cancel=True
that solved the problem. I was trying:

If IsNull(Me.cbo_Cust) Then
mbrResponse = MsgBox("Need to select Customer" , vbOKOnly, "Enter
Customer")
Me.cbo_Cust.SetFocus
End If

The SetFocus just did not work, I have not heard about the "Cancel"
instruction before, but when I changed "Me.cbo_Cust.SetFocus" to
"Cancel=True" it worked the way I wanted.

Garry


fredg said:
Ricky,
checking for IsNull or IsEmpty in the Before Update event does not work.
If I hit Tab or Enter without entering anything, focus "happily" moves on to
the next control. I would like to trap this before focus goes to the next
control.
Garry

Does this help?
Code the Combo Box Exit event:
If IsNull(Me![ComboName]) or Me![ComboName] = "" Then
MsgBox "You must enter a value." ' Optional message
Cancel = True
End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top