Use the Not In List event of the combo box. The Limit To List property
must be set to True for it to work. Here is an example of a simple
Not In List event procedure. Depending on your version of Access and
your References, this may or may not work for you exactly as it is written,
but it should give you an idea of how it works. You can also find info
in Access help or online.
Private Sub cboCities_NotInList(NewData As String, Response As Integer)
Dim strMsg As String
Dim strSQL As String
strMsg = """" & NewData & """ is not in the list" & vbNewLine
strMsg = strMsg & "Do you want to add it?"
If MsgBox(strMsg, vbInformation + vbYesNo, "New City") = vbYes Then
Response = acDataErrAdded
strSQL = "Insert Into tblCities ([CityName]) Values(""" & NewData & """);"
CurrentDb.Execute strSQL, dbFailOnError
Else
Response = acDataErrContinue
End If
End Sub
--
_________
Sean Bailey
RS Controls said:
i have a form that has a city entry point (combobox) i have a table with SOME
city names in it (not all)when i give focus to the combo and type in the
first letter it list the city names acordingly if its in the city table. how
do i update the city table with the new city name i type in ?