+ Reply to Thread
Results 1 to 2 of 2

syntax error in insert into statement in vba

  1. #1
    Registered User
    Join Date
    12-16-2008
    Location
    india
    Posts
    4

    Post syntax error in insert into statement in vba

    Hi

    i got a error while insert a data. if same query i run in ms access its working row append.

    but code through means its show error. pls help us.

    Coding

    Public db As New ADODB.Connection
    .....
    .....

    vquery1 = "INSERT INTO DCD (PROD,TYPE,MONTH,AGEINGBRACKET,OCREF,PARTYNAME,INVQTY,FREIGHT,CFEXPENSES,COMMISSION) VALUES ('" & VPROD & "','" & VTYPE & "','" & VMONTH & "','" & VAGEINGBRACKET & "','" & VOCREF & "','" & VPARTYNAME & "'," & VINVQTY & "," & vpassvalue & ")"

    db.Execute vquery1

    query with values:

    INSERT INTO DCD (PROD,TYPE,MONTH,AGEINGBRACKET,OCREF,PARTYNAME,INVQTY,FREIGHT,CFEXPENSES,COMMISSION) VALUES ('AV','1.BOOKED','2011 10 OCTOBER','6 - 9 Months','1/A/01','HAJI NOOR',20.344,0,0,0)

    advanced thanks

  2. #2
    Forum Contributor tkowal's Avatar
    Join Date
    11-20-2010
    Location
    Miami, Fl
    MS-Off Ver
    Excel 2010
    Posts
    150

    Re: syntax error in insert into statement in vba

    What is the error?

    A lot of things can go wrong the same query in access will not necessarily run in vba... some common things to look for:

    1. Make sure the text is text and number are really numbers. ACCESS typecast them differently than VBA
    2. Are there embedded punctionations like quotes " commas , single quotes ' in the text that you are trying to insert
    3. How is if failing.... did you print out the vquery in immediate mode to see the structure and the variable substitutions?
    Ted
    "Live Long and Prosper"

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1