Results 1 to 6 of 6
  1. #1
    mdiaz is offline Novice
    Windows XP Access 2007
    Join Date
    Nov 2011
    Posts
    4

    Help with Insert Into Error


    I created this form that users can enter data into and click on a button to add the data to a table. I can not seem to find the issue. Each time I run it i get the Run-Time error '3134' Syntax error in INSERT INTO statement. The code is below any help will be appreciated.

    Private Sub cmdAdd_Click()
    'add data to table
    CurrentDb.Execute "INSERT INTO Production(Date of Data, New Referrals 1st Stage, New Referrals 2nd Stage, Email Submatters, Query Submatters, BK Referrals, Evictions, Military Searches Completed, Military Searches Follow Up, Missing Document Follow Up, Transfer Foreclosure Referrals, Transfer DE - FO FIle Opened)" & _
    " VALUES(" & Me.cbodate & ",'" & Me.txtnr1 & "','" & Me.txtnr2 & "','" & Me.txtemail & "','" & _
    Me.txtquery & "','" & Me.txtbky & "','" & Me.txteviction & "','" & Me.txtmilcomp & "','" & Me.txtmilfu & "','" & _
    Me.txtmissingdoc & "','" & Me.txttransferfc & "','" & Me.txttransferde & "')"

    'refresh data in list on form
    frmproductionsub.Form.Requery
    End Sub

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,530
    This should help:

    http://www.baldyweb.com/ImmediateWindow.htm

    Offhand, the inadvisable spaces and symbols in field names require the names to be bracketed and the date value would need to be surrounded by #.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    mdiaz is offline Novice
    Windows XP Access 2007
    Join Date
    Nov 2011
    Posts
    4
    Sorry i am fairly new to this could you point out where i need to make the changes?

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,530
    What were the results of the Debug.Print? Have you added brackets to your field names?

    [Date of Data]
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    mdiaz is offline Novice
    Windows XP Access 2007
    Join Date
    Nov 2011
    Posts
    4
    Your awesome it worked, thanks for your help.

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,530
    No problem, and welcome to the site by the way!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. INSERT query: insert new data only
    By drh in forum Access
    Replies: 2
    Last Post: 04-04-2014, 05:31 PM
  2. insert into error
    By jscriptor09 in forum Access
    Replies: 1
    Last Post: 07-10-2011, 11:42 AM
  3. INSERT INTO Syntax Error
    By eww in forum Programming
    Replies: 1
    Last Post: 04-06-2011, 10:28 AM
  4. SQL INSERT INTO Date Syntax Error
    By tuna in forum Programming
    Replies: 5
    Last Post: 08-10-2010, 06:17 AM
  5. Syntax Error In Insert Into Statement
    By frankvfox in forum Queries
    Replies: 1
    Last Post: 09-09-2008, 12:35 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums