Not in Combo List

  • Thread starter Thread starter Ken Ivins
  • Start date Start date
K

Ken Ivins

I would like some help on coding. I have a Combo box that is exporting the
ID field but shows the name field. It is used to auto fill in data. The
problem is that users (darn users they will do anything you don't expect)
will start typing to see if a record is in the drop down list, and if not
will just go to the name field to add a new record while leaving information
in the combo box that tries to execute my code based on non existing data.
So an error will appear saying it can not find the partial data they just
entered.

So I would like to create an "If" statement which looks at the list and if
the data in the combo box Me.CmbckPayableToID is not on the list (including
blank) then it will just move to the txbptPayableTo field. Else do what
I have the code already doing.

My problem is how do I have it look at the list from the query
qryddPayableTo in the ptPayableTo field to see if that info is there? I'm
sure this is simple but a skill I have not learned yet.

Thanks, for your help.

Ken
 
You might try a different approach. Use the combobox's NotInList event to do
what you seek.

Private Sub ComboBoxName_NotInList((NewData As String, Response As Integer)
Response = acDataErrContinue
If vbYes = MsgBox("This value is not in the combo " & _
"box's list. Do you want to go to the Payable To " & _
"box?", vbQuestion+vbYesNo, "Payable To?") Then
Me.txbptPayableTo.SetFocus
Else
MsgBox "Select a value from the list.", vbExclamation, _
"Select A Value"
End If
End Sub
 
Back
Top