
If not in combo list, then add to the list
Goto?? AHHHHHH!!!! Just messing with you Richard. James, here's a
clarification for you, minus the Goto.
Private Function IsInList(ByRef cbx as ComboBox, ByVal NewValue as String)
as Boolean
For X = 0 To cbx.ListCount-1
If cbx.list(x) = NewValue Then
IsInList = True
Exit Function
End If
Next X
End Sub
Private Sub AddNewTown(ByRef cbx as ComboBox, ByVal NewValue as String)
''''''Insert Code here to save it to your database
cbx..Additem Combo1.Text 'Adds Town to the list
End Sub
Private Sub Combo1_KeyPress(keyascii As Integer)
Dim X as Integer
If keyascii = vbKeyEnter Then
For X = 0 To Combo1.ListCount -1
If Left(Combo1.List(X), Len(Combo1,Text)) = Combo1.Text Then
Combo1.Text = Combo1.List(x)
Exit For
End If
Next X
Else
If Not IsInList(Combo1, Combo1.Text) Then Call AddNewTown(Combo1,
Combo1.Text)
End If
End Sub
There it is on a silver platter...