I have a combo box on a form i'm trying to use the not in list event....
I'm getting an error when trying to imput a value in the combo box..
My errror says error with Inster Into Syntax...
Here's my code
Private Sub Firm_Description_NotInList(NewData As String, Response As Integer)
On Error GoTo Firm_Description_NotInList_Err
Dim intAnswer As Integer
Dim strSQL As String
intAnswer = MsgBox("The firm " & Chr(34) & NewData & _
Chr(34) & " is not currently in the database." & vbCrLf & _
"Would you like to add it to the list now?" _
, vbQuestion + vbYesNo, "Prospect Database")
If intAnswer = vbYes Then
strSQL = "INSERT INTO Firm ID([Firm_Description]) " & _
"VALUES ('" & NewData & "');"
DoCmd.SetWarnings False
DoCmd.RunSQL strSQL
DoCmd.SetWarnings True
MsgBox "The new firm has been added to the list." _
, vbInformation, "Prospect Database"
Response = acDataErrAdded
Else
MsgBox "Please choose a firm from the list." _
, vbInformation, "Prospect Database"
Response = acDataErrContinue
End If
Firm_Description_NotInList_Exit:
Exit Sub
Firm_Description_NotInList_Err:
MsgBox Err.Description, vbCritical, "Error"
Resume Firm_Description_NotInList_Exit
End Sub
I'm getting an error when trying to imput a value in the combo box..
My errror says error with Inster Into Syntax...
Here's my code
Private Sub Firm_Description_NotInList(NewData As String, Response As Integer)
On Error GoTo Firm_Description_NotInList_Err
Dim intAnswer As Integer
Dim strSQL As String
intAnswer = MsgBox("The firm " & Chr(34) & NewData & _
Chr(34) & " is not currently in the database." & vbCrLf & _
"Would you like to add it to the list now?" _
, vbQuestion + vbYesNo, "Prospect Database")
If intAnswer = vbYes Then
strSQL = "INSERT INTO Firm ID([Firm_Description]) " & _
"VALUES ('" & NewData & "');"
DoCmd.SetWarnings False
DoCmd.RunSQL strSQL
DoCmd.SetWarnings True
MsgBox "The new firm has been added to the list." _
, vbInformation, "Prospect Database"
Response = acDataErrAdded
Else
MsgBox "Please choose a firm from the list." _
, vbInformation, "Prospect Database"
Response = acDataErrContinue
End If
Firm_Description_NotInList_Exit:
Exit Sub
Firm_Description_NotInList_Err:
MsgBox Err.Description, vbCritical, "Error"
Resume Firm_Description_NotInList_Exit
End Sub