title: Getting "Syntax error in INSERT INTO" for Append Query in VBA (Access 2002)
body: <p>I am getting a "Syntax error in INSERT INTO" when I try to run an append query.</p>
  
  <p>I'm making a database to make it easier on production operators; capturing some of the data by hand-held scanners.</p>
  
  <p>I've been looking around to see if anybody has had a problem like this.  I've seen some that were close, but when I've made the minor changes to my code, I still get the syntax error. </p>
  
  <p>I am using an unbound form for data-entry purposes, but I need to capture the data from the form and add it to two different tables.  Trying to run the DoCmd.RunSQL is when the error occurs.  As far as I can tell the code, and SQL looks correct.</p>
  
  <p>Here is the entire code for my procedure.
  Code:</p>
  
  <pre><code>Private Sub cmdNext_Click()
  
  On Error GoTo Err_cmdNext_Click
  'Append table: tblScan with the Badge Number, Part #/ICS#, Lot # (if available), Press (i.e. MD01), Shift, and the current
  '                   Date/Time (captured with this code).
  'Append table: tblJob with Press, Part#/ICS#, and the current Date/Time (captured with this code).
  Dim strBadge As String
  Dim strPress As String
  Dim dtmDate As Variant
  Dim strSQL As String
  Dim strMessage As String
  Dim strTitle As String
  Dim varQuestion As Variant
  
  
  strMessage = "You have not entered a correct "
  strTitle = "ERROR MISSING or INCORRECT INFORMATION!"
  strSQL = ""
  dtmDate = Now
  
  If IsNull(Me!cboBadgeNum.Column(1)) Then
      strMessage = strMessage &amp; "Badge Number.  Please scan the operator's badge before continuing."
      varQuestion = MsgBox(strMessage, vbOKOnly + vbCritical + vbSystemModal, strTitle)
      Me!cboBadgeNum.SetFocus
      GoTo Exit_cmdNext_Click
  Else
      strBadge = Me!cboBadgeNum.Column(1)
  End If
  
  
  If IsNull(Me!cboPress.Column(1)) Then
      strMessage = strMessage &amp; "Press.  Please select the press where this job was run before continuing."
      varQuestion = MsgBox(strMessage, vbOKOnly + vbCritical + vbSystemModal, strTitle)
      Me!cboPress.SetFocus
      GoTo Exit_cmdNext_Click
  Else
      strPress = Me!cboPress.Column(1)
  End If
  
  If gstrICS = " " Then
      strMessage = strMessage &amp; "ICS Number.  Please Enter a valid ICS Number before continuing."
      varQuestion = MsgBox(strMessage, vbOKOnly + vbCritical + vbSystemModal, strTitle)
      txtICS.SetFocus
      GoTo Exit_cmdNext_Click
  ElseIf gstrICS = "" Then
      strMessage = strMessage &amp; "ICS Number.  Please Enter a valid ICS Number before continuing."
      varQuestion = MsgBox(strMessage, vbOKOnly + vbCritical + vbSystemModal, strTitle)
      txtICS.SetFocus
      GoTo Exit_cmdNext_Click
  End If
  
  If gstrLot = "" Then
      strMessage = strMessage &amp; "Lot Number.  Please Enter a valid Lot Number before continuing."
      varQuestion = MsgBox(strMessage, vbOKOnly + vbCritical + vbSystemModal, strTitle)
      txtLot.SetFocus
      GoTo Exit_cmdNext_Click
  End If
  
  'Use an Apend query to update Scan table.   
  **strSQL = "INSERT INTO tblScan (BadgeNum, PartNum, LotNum, Press, Shift, ScanDate) " &amp; vbCrLf
  strSQL = strSQL &amp; "VALUES  (" &amp; Chr(34) &amp; strBadge &amp; Chr(34) &amp; ", "
  strSQL = strSQL &amp; Chr(34) &amp; gstrICS &amp; Chr(34) &amp; ", "
  strSQL = strSQL &amp; Chr(34) &amp; gstrLot &amp; Chr(34) &amp; ", "
  strSQL = strSQL &amp; Chr(34) &amp; strPress &amp; Chr(34) &amp; ", "
  strSQL = strSQL &amp; gShift &amp; ", "
  strSQL = strSQL &amp; "#" &amp; dtmDate &amp; "#);"**
  
  
  DoCmd.SetWarnings False
  DoCmd.RunSQL strSQL
  DoCmd.SetWarnings True
  
  'Use an Apend query to update Job table.
  **strSQL = "INSERT INTO Job (Press, PartNum, StartDate) "
  strSQL = strSQL &amp; "VALUES (" &amp; Chr(34) &amp; strPress &amp; Chr(34) &amp; ", "
  strSQL = strSQL &amp; Chr(34) &amp; gstrICS &amp; Chr(34) &amp; ", "
  strSQL = strSQL &amp; "Job.JobDate = #" &amp; dtmDate &amp; "#);"**
  
  
  'DoCmd.SetWarnings False
  DoCmd.RunSQL strSQL
  DoCmd.SetWarnings True
  
  lblFirstName.Caption = " "
  lblLastName.Caption = " "
  txtICS.SetFocus
  txtICS.Text = " "
  txtLot.SetFocus
  txtLot.Text = " "
  cboBadgeNum.SetFocus
  cboBadgeNum.Value = 0
  
  DoCmd.Close
  
  
  Exit_cmdNext_Click:
  Exit Sub
  
  Err_cmdNext_Click:
  MsgBox Err.Description
  Resume Exit_cmdNext_Click
  
  End Sub
  </code></pre>
  
  <p>I've temporarily disabled the "DoCmd.SetWarnings" until I get the query to update the tables.</p>
  
  <p>Thank you in advance for any assistance/help.  It will be extremely helpful.</p>