Alhakeem1977
Registered User.
- Local time
- Today, 07:37
- Joined
- Jun 24, 2017
- Messages
- 308
I have got a code to fire in (not in list) event of a combobox to add two values in a table called: tblCompanies but it's not working getting error: Run-time error '3134' Syntax error in INSERT INRO.
Any help is highly appreciated?
Any help is highly appreciated?
Code:
Private Sub cboComp_NotInList(NewData As String, Response As Integer)
Dim strTmp As String
'Get confirmation that this is not just a spelling error.
strTmp = "Add '" & NewData & "' as a new company?"
If MsgBox(strTmp, vbYesNo + vbDefaultButton2 + vbQuestion, "Not in list") = vbYes Then
'Append the NewData as a record in the Categories table.
strTmp = "INSERT INTO tblCompanies ( Company, CompCountry ) " & _
"SELECT """ & NewData & """ AS cboComp, AS cboCountryID;"
DBEngine(0)(0).Execute strTmp, dbFailOnError
'Notify Access about the new record, so it requeries the combo.
Response = acDataErrAdded
End If
End Sub