title: Microsoft Access VBA INSERT SQL statement
body: <p>I have created a database within Microsoft access and with it a form.<br>
  I have a button attached to the form and when it's clicked I want to insert a new record into the table <code>customerHeader</code>.<br>
  There are four fields within that table one being an autonumber.  In my SQL statement, I don't include the orderNumber since it is an autofield.<br>
  When I try to click the button and the on click event is executed, I get an error saying that Microsoft Access cannot append the records in the append query.  </p>
  
  <p>Any ideas, I have looked everywhere and I have not been able to find the solution.</p>
  
  <pre><code>Private Sub addOrder_Click()
      Dim mySql As String
      Dim rowNum As Integer
      Dim recCount As Long
      Dim orderNumber As Long
      Dim myBool As Boolean
  
  
      Dim todayDate As Date
  
      todayDate = CDate(Date)
  
      myBool = False
  
  
      MsgBox todayDate
  
      rowNum = Form.CurrentRecord
      rowNum = CInt(rowNum - 1)
  
  
  
      'DoCmd.GoToRecord , , acNewRec
      mySql = "INSERT INTO orderHeader (orderDate,custNumber,printed) VALUES (" &amp; todayDate &amp; "," &amp; rowNum &amp; "," &amp; myBool &amp; ")"
  
      DoCmd.RunSQL mySql
  
      Me!orderNum.Requery
  </code></pre>