I'm probably missing something really easy here. I have the following block of code:
Code:
If Category = "Client" Then
SQLAddtask = "INSERT INTO CM_Task (TaskType, OpenDate, Client) VALUES('" & TType & "', #" & Date & "#, '" & CType & "')"
ElseIf Category = "Desk" Then
SQLAddtask = "INSERT INTO CM_Task (TaskType, OpenDate, Desk) VALUES('" & TType & "', #" & Date & "#, '" & CType & "')"
ElseIf Category = "Group" Then
SQLAddtask = "INSERT INTO CM_Task (TaskType, OpenDate, Group) VALUES('" & TType & "', #" & Date & "#, '" & CType & "')"
ElseIf Category = "Campaign" Then
SQLAddtask = "INSERT INTO CM_Task (TaskType, OpenDate, Campaign) VALUES('" & TType & "', #" & Date & "#, '" & CType & "')"
ElseIf Category = "Project" Then
SQLAddtask = "INSERT INTO CM_Task (TaskType, OpenDate, Project) VALUES('" & TType & "', #" & Date & "#, '" & CType & "')"
End If
MsgBox SQLAddtask
DoCmd.SetWarnings False
DoCmd.RunSQL SQLAddtask
DoCmd.SetWarnings True
Everything executes perfectly except for when Category = Group. I've looked at the resulting code in a message box and it looks fine to me. I get an error message stating that there is a sytax error in the INSERT INTO Statement. The entry for Group in this statment is 'G50'. Can anybody spot anything?