Results 1 to 7 of 7

Thread: Run Time error '3134' Syntax error in INSERT INTO statement

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2012
    Posts
    2

    Run Time error '3134' Syntax error in INSERT INTO statement

    I can't for the life of me figure this out. The syntax looks good to me. Any help would be appreciated.

    thanks

    CurrentDb.Execute "Insert Into RulesNotCrD(AccountName, Note) Values ('" & Me.cboAcName & "','" & Me.Text18 & "')"

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Run Time error '3134' Syntax error in INSERT INTO statement

    Have you checked what that actual string looks like? Never assume that the data you are using is what you think it is when it doesn't work. Always check.
    Code:
    MsgBox "Insert Into RulesNotCrD(AccountName, Note) Values ('" & Me.cboAcName & "','" & Me.Text18 & "')"
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    New Member
    Join Date
    Feb 2012
    Posts
    2

    Re: Run Time error '3134' Syntax error in INSERT INTO statement

    It is the use of the column name 'Note'. It's a reserved word. So it either needs to be placed in brackets or another name needs to be used.

    thanks!

    Here's a link to a list of reserved words:

    http://support.microsoft.com/default...b;en-us;286335

  4. #4
    Wall Poster TysonLPrice's Avatar
    Join Date
    Sep 2002
    Location
    Columbus, Ohio
    Posts
    3,969

    Re: Run Time error '3134' Syntax error in INSERT INTO statement

    Quote Originally Posted by daveinchicago View Post
    It is the use of the column name 'Note'. It's a reserved word. So it either needs to be placed in brackets or another name needs to be used.

    thanks!

    Here's a link to a list of reserved words:

    http://support.microsoft.com/default...b;en-us;286335
    That must depend on the database because in SQL Server 2005 this works just fine:

    create table RulesNotCrD(AccountName char(10), Note char(20))
    Insert Into RulesNotCrD(AccountName, Note) Values ('TestIt', 'TestNote')
    select * from RulesNotCrD
    drop table RulesNotCrD

  5. #5
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Run Time error '3134' Syntax error in INSERT INTO statement

    It does depend on the database system, and various other things too (such as the driver/provider you are using to connect), which is why multiple lists are given for various items in the article What names should I NOT use for tables/fields/views/stored procedures/...? from our Database Development FAQs/Tutorials (at the top of this forum)

  6. #6
    New Member
    Join Date
    Jun 2015
    Posts
    1

    Re: Run Time error '3134' Syntax error in INSERT INTO statement

    I have the same Issue I cant figure this out, whats wrong with this??


    CurrentDb.Execute "INSERT INTO BillTabe(ID, Venor, TxnDate, RefNumber, LineItem, LineDesc, LineQty, LineBillableEntity, LineUnitPrice, LineAmount, LineBillableStatus)" & _
    " VALUE(" & Me.txtID & "','" & Me.cboVendor & "','" & Me.txtTxnDate & "','" & Me.txtRefNumber & "','" & Me.txtLineItem & "','" & Me.txtLineDesc & "','" & Me.txtLineQty & "','" & _
    Me.cboLineBillableEntity & "','" & Me.txtLineUnitPrice & "','" & Me.txtLineAmount & "','" & Me.txtLineBillableStatus & "')"

  7. #7
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Run Time error '3134' Syntax error in INSERT INTO statement

    Quote Originally Posted by dpacheco30 View Post
    I have the same Issue I cant figure this out, whats wrong with this??


    CurrentDb.Execute "INSERT INTO BillTabe(ID, Venor, TxnDate, RefNumber, LineItem, LineDesc, LineQty, LineBillableEntity, LineUnitPrice, LineAmount, LineBillableStatus)" & _
    " VALUE(" & Me.txtID & "','" & Me.cboVendor & "','" & Me.txtTxnDate & "','" & Me.txtRefNumber & "','" & Me.txtLineItem & "','" & Me.txtLineDesc & "','" & Me.txtLineQty & "','" & _
    Me.cboLineBillableEntity & "','" & Me.txtLineUnitPrice & "','" & Me.txtLineAmount & "','" & Me.txtLineBillableStatus & "')"
    Did you bother to read post #2 and do what it says? It would appear not. If you have the same problem then maybe follow the same advice.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width