The following code is supposed to enable to user to add new items to a combo box. It worked fine in Access 2007, but results in an error in Access 2010.
The offer is made to add a new item, but then when you attempt to do so a message comes "Error 3075 (Syntax error (missing operator) in query expression). I assume it's in the line
strSql = "Insert Into tblAwards ([Award]) values ('" & NewData & "')"
Can anyone advise how to rectify this? Thanks!
The offer is made to add a new item, but then when you attempt to do so a message comes "Error 3075 (Syntax error (missing operator) in query expression). I assume it's in the line
strSql = "Insert Into tblAwards ([Award]) values ('" & NewData & "')"
Can anyone advise how to rectify this? Thanks!
Code:
Private Sub Award_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
On Error GoTo Award_NotInList_Error
On Error GoTo cboIns_NotInList_Error
If NewData = "" Then Exit Sub
Msg = """" & NewData & """ is not currently in the list." & vbCr & vbCr
Msg = Msg & "Do you want to add this Award?"
i = MsgBox(Msg, vbQuestion + vbYesNo, "Unknown Name...")
If i = vbYes Then
strSql = "Insert Into tblAwards ([Award]) values ('" & NewData & "')"
DoCmd.SetWarnings False
CurrentDb.Execute strSql
Response = acDataErrAdded
DoCmd.SetWarnings True
Else
Response = acDataErrContinue
End If
On Error GoTo 0
Exit Sub
cboIns_NotInList_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure cboIns_NotInList of VBA Document Form_frmMembers"
On Error GoTo 0
Exit Sub
Award_NotInList_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure Award_NotInList of VBA Document Form_fsubAwardsGiven"
End Sub