S
Song Su
Access 2007
After confirm OK to add new data, it still prompt me "The text you entered
isn't an item in the list" with OK. Click again, it goes back to my combo
and newly added data is not in combo. Then I opened the table, the newly
added record has been added in the table. What's wrong with my NotInList
event? my PONumber is text field primary key. Here is the code:
Private Sub cboPO_NotInList(NewData As String, Response As Integer)
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 = "Add new PO?"
i = MsgBox(Msg, vbQuestion + vbYesNo, "Unknown PO")
If i = vbYes Then
strSQL = "Insert Into POs ([PONumber]) " & _
"values ('" & NewData & "');"
CurrentDb.Execute strSQL, dbFailOnError
Response = acDataErrAdded
Else
Response = acDataErrContinue
End If
End Sub
After confirm OK to add new data, it still prompt me "The text you entered
isn't an item in the list" with OK. Click again, it goes back to my combo
and newly added data is not in combo. Then I opened the table, the newly
added record has been added in the table. What's wrong with my NotInList
event? my PONumber is text field primary key. Here is the code:
Private Sub cboPO_NotInList(NewData As String, Response As Integer)
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 = "Add new PO?"
i = MsgBox(Msg, vbQuestion + vbYesNo, "Unknown PO")
If i = vbYes Then
strSQL = "Insert Into POs ([PONumber]) " & _
"values ('" & NewData & "');"
CurrentDb.Execute strSQL, dbFailOnError
Response = acDataErrAdded
Else
Response = acDataErrContinue
End If
End Sub