Run-Time Error 3134 - Syntax Error in Insert Into Statement
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 5 of 5

Thread: Run-Time Error 3134 - Syntax Error in Insert Into Statement

  1. #1
    Board Regular
    Join Date
    Sep 2013
    Posts
    76
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Run-Time Error 3134 - Syntax Error in Insert Into Statement

    Hi -

    I have an Insert Into Statement in my VBA code and I keep getting a run-time error 3134. I know there are a number of posts about this type of problem and I have tried all of the solutions I have found but nothing seems to work for this particular string. If someone sees the issue, can you please point it out? Thanks.

    Code:
    strSQL = "INSERT INTO tblPDcalc ([Month End], [Loan Type], [FICO Band], [r1PD], [r2PD], [r3PD], [r4PD], [r5PD], " _
            & "SELECT (#" & modeldate & "#, '1st Mtg', '1', " _
            & " " & r1PD & ", " & r2PD & ", " & r3PD & ", " & r4PD & ", " & r5PD & ");"
    
    
    DoCmd.RunSQL (strSQL)

  2. #2
    Moderator mole999's Avatar
    Join Date
    Oct 2004
    Location
    UK
    Posts
    8,924
    Post Thanks / Like
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Run-Time Error 3134 - Syntax Error in Insert Into Statement

    double speech marks on beginning of line three look suspicious to me
    • Yes I know there are better ways to do it. I just wish I knew them. - 2003, 2007, 2010, 2013 & 2016
    • I wear my ignorance openly, excel is not my chosen career, its a means to an ends
    • Posting Guidelines Want to post well laid out questions and answers Translate Excel Versions
      Code:
      [CODE ]Put Your Code[/ CODE]
    • Settings > General Settings (on the left) scroll to the bottom, > Miscellaneous Options > Use ENHANCED
    • X-Posting Guidelines Rule 13 > CHART STUFF

  3. #3
    Board Regular Norie's Avatar
    Join Date
    Apr 2004
    Location
    Stirling, Scotland
    Posts
    73,540
    Post Thanks / Like
    Mentioned
    22 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Run-Time Error 3134 - Syntax Error in Insert Into Statement

    Why are you using SELECT when the values you are inserting aren't coming from a table/query.

    This is the syntax for inserting values:

    INSERT INTO table_name (column1,column2,column3,...)
    VALUES (value1,value2,value3,...);
    If posting code please use code tags.

  4. #4
    MrExcel MVP
    Moderator
    xenou's Avatar
    Join Date
    Mar 2007
    Location
    Clev. OH, USA
    Posts
    15,812
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)

    Default Re: Run-Time Error 3134 - Syntax Error in Insert Into Statement

    You are missing a closing parentheses (and have an extra comma too, I think).

    Are the value you are "selecting" supposed to come from a table, or are they literal values. It looks like literal values. The correct sql should be something like:

    Code:
    INSERT INTO TblPDCalc ( Field1, Field2, Field3, .... )
    VALUES ( Value1, Value2, Value3, ... )

    Using: Office 2010/Win7 (work) Office 2010/Win7 (home)

    You are rich in proportion to the number of things you can let alone.
    -- Henry David Thoreau

  5. #5
    Board Regular
    Join Date
    Sep 2013
    Posts
    76
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Run-Time Error 3134 - Syntax Error in Insert Into Statement

    Thanks for the responses. I was able to get the code to work now! Here is the final code in case anyone else needs something similar:
    Code:
     
    'Append PD calculations to tblPDcalc
    strSQL = "INSERT INTO tblPDcalc ([Month End], [Loan Type], [FICO Band], [r1PD], [r2PD], [r3PD], [r4PD], [r5PD]) " _
            & "VALUES (#" & modeldate & "#, '1st Mtg', '1', " & r1PD & ", " & r2PD & ", " & r3PD & ", " & r4PD & ", " & r5PD & ");"
    
    
    DoCmd.RunSQL (strSQL)
    Last edited by davidb88; Jan 28th, 2014 at 02:51 PM.

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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

 

DMCA.com