I have the code below with a split database (front/back-end). I enter information that isn’t in the list and get the following “The text you entered wasn’t an item in the list, select an item in the list” when selecting a combo box. The code seems to be working as the new city is entered into the table just the combo box isn’t refreshing to show or refresh to the new data
It really has me scratching my head. (I realise that haven’t closed the DB connection)
I tried requery on the form (then the error got into a loop – recurring). The data field is text, not euro, that is illustrated by Microsoft as having problems.
The underlying data has changed just not displaying it on the form.
Any suggestions would be greatly appreciated.
Thanks Todd
Private Sub ComboCity_NotInList(NewData As String, Response As Integer)
' If the new item isn't in the list it asks if you would like to add it
Dim strSQL As String
Dim i As Integer
Dim Msg As String
'Exit this sub if the combo box is cleared
If NewData = "" Then Exit Sub
Msg = "'" & NewData & "' is not currently in the city list." & vbCr & vbCr
Msg = Msg & "Do you want to add it?"
i = MsgBox(Msg, vbQuestion + vbYesNo, "Unknown City...")
If i = vbYes Then
strSQL = NewData
' Opens the DB connection
Call OpenConnection
'calls the sub below
ExecuteSQL (strSQL)
Response = acDataErrAdded
Else
Response = acDataErrContinue
End If
End Sub
‘In the module section
Public conDb As ADODB.Connection
Public Sub OpenConnection()
Dim strDBPath As String
strDBPath = "MarkBe.mdb"
' Initialize Connection object
Set conDb = New ADODB.Connection
With conDb
.ConnectionString = strDBPath
' Specify Microsoft Jet 4.0 Provider and then open the
' database specified in the strDBPath variable.
.Provider = "Microsoft.Jet.OLEDB.4.0"
.Open strDBPath
End With
' Close Connection object and destroy object variable.
' cnnDB.Close
' Set cnnDB = Nothing
End Sub
Public Function ExecuteSQL(strSQL As String) As Recordset
Dim rst As New ADODB.Recordset
Dim cmd As ADODB.Command
Set rst = New ADODB.Recordset
Set rst.ActiveConnection = conDb
rst.CursorLocation = adUseClient
rst.CursorType = adOpenKeyset
rst.LockType = adLockOptimistic
rst.Open "tCity", , , , adCmdTable
rst.AddNew
rst!CityName = strSQL
rst.Update
rst.Requery
rst.Close
End Function
It really has me scratching my head. (I realise that haven’t closed the DB connection)
I tried requery on the form (then the error got into a loop – recurring). The data field is text, not euro, that is illustrated by Microsoft as having problems.
The underlying data has changed just not displaying it on the form.
Any suggestions would be greatly appreciated.
Thanks Todd

Private Sub ComboCity_NotInList(NewData As String, Response As Integer)
' If the new item isn't in the list it asks if you would like to add it
Dim strSQL As String
Dim i As Integer
Dim Msg As String
'Exit this sub if the combo box is cleared
If NewData = "" Then Exit Sub
Msg = "'" & NewData & "' is not currently in the city list." & vbCr & vbCr
Msg = Msg & "Do you want to add it?"
i = MsgBox(Msg, vbQuestion + vbYesNo, "Unknown City...")
If i = vbYes Then
strSQL = NewData
' Opens the DB connection
Call OpenConnection
'calls the sub below
ExecuteSQL (strSQL)
Response = acDataErrAdded
Else
Response = acDataErrContinue
End If
End Sub
‘In the module section
Public conDb As ADODB.Connection
Public Sub OpenConnection()
Dim strDBPath As String
strDBPath = "MarkBe.mdb"
' Initialize Connection object
Set conDb = New ADODB.Connection
With conDb
.ConnectionString = strDBPath
' Specify Microsoft Jet 4.0 Provider and then open the
' database specified in the strDBPath variable.
.Provider = "Microsoft.Jet.OLEDB.4.0"
.Open strDBPath
End With
' Close Connection object and destroy object variable.
' cnnDB.Close
' Set cnnDB = Nothing
End Sub
Public Function ExecuteSQL(strSQL As String) As Recordset
Dim rst As New ADODB.Recordset
Dim cmd As ADODB.Command
Set rst = New ADODB.Recordset
Set rst.ActiveConnection = conDb
rst.CursorLocation = adUseClient
rst.CursorType = adOpenKeyset
rst.LockType = adLockOptimistic
rst.Open "tCity", , , , adCmdTable
rst.AddNew
rst!CityName = strSQL
rst.Update
rst.Requery
rst.Close
End Function