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

How to tell User typed value not in list without Limit to List

Status
Not open for further replies.

Jean9

Programmer
Dec 6, 2004
128
US
I have added a combo box to a form that I want the User to be able to type in a value to that is not in the list. I don't want to use the limit to list property unless there is way to get past the limit and continue processing without adding the value the user typed in to the list. I want to catch the "notInList" at a later processing point. How can I tell when the user has typed in a value that is not in the list without using NotInList (I'd prefer to avoid another db call to check for this value in the table)
Thanks,
J9
 
I can not understand why you want to do this, it does not make sense to me.

Code:
Public Function isInList(ctrl As Access.ComboBox) As Boolean
  Dim counter As Integer
  For counter = 0 To ctrl.ListCount - 1
      If ctrl.Text = ctrl.ItemData(counter) Then
        isInList = True
      End If
    Next counter
 End Function

Private Sub Combo9_BeforeUpdate(Cancel As Integer)
  MsgBox isInList(Me.Combo9)
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top