Quantcast
Channel: dBforums – Everything on Databases, Design, Developers and Administrators
Viewing all articles
Browse latest Browse all 13329

NotInList error message

$
0
0
I am not very good with writing code so please be gentle with me. I have written NotInList code and it works in all but one of my databases. I am getting the following message "The text you entered isn't an item on the list - Select an item on the list or enter text that matches one of the listed items" when I look at the table the new entry is there - so why can't I select it?

Below is the code. Where am I going wrong?

Private Sub cmboAccount_number_NotInList(NewData As String, Response As Integer)
On Error GoTo cmboAccountNumber_NotInList_Err
Dim intAnswer As Integer
Dim strSql As String
intAnswer = MsgBox("The account number " & Chr(34) & NewData & Chr(34) & " is not currently listed." & vbCrLf & "Would you like to add it to the list now?", vbQuestion + vbYesNo, "tblAccountNumber")
If intAnswer = vbYes Then
strSql = "INSERT INTO tblAccountNumber([Account Number]) " & "VALUES ('" & NewData & "');"
DoCmd.SetWarnings False
DoCmd****nSQL strSql
DoCmd.SetWarnings True
MsgBox "The new account number has been added to the list.", vbInformation, "tblAccountNumber"
Response = acDataErrAdded
Else
MsgBox "Please choose an account number from the list.", vbInformation, "tblAccountNumber"
Response = acDataErrContinue
End If
cmboAccountNumber_NotInList_Exit:
Exit Sub
cmboAccountNumber_NotInList_Err:
MsgBox Err.Description, vbCritical, "Error"
Resume cmboAccountNumber_NotInList_Exit
End Sub

Viewing all articles
Browse latest Browse all 13329

Trending Articles