Troubleshoot a INSERT INTO statement in Excel

  • Everything is functioning correctly except to "INSERT INTO" statement. Could someone help troubleshoot it with me.


  • Re: Troubleshoot a INSERT INTO statement in Excel


    Have you examined thisSQL when all the variable values have been added?


    It's hard for us to do that because we don't know what those values are.


    Just looking at the code and the SQL one thing I do notice is that you appear to have square brackets round each value you are inserting.


    Square brackets are normally used for field/table etc names not values.

    Boo!:yikes:

  • Re: Troubleshoot a INSERT INTO statement in Excel


    Whatis the error message you are receiving?


    Also, run it with a debug.print in it - as below- and post what is shown in the Immeadiate Window.


    As norie said on first glance the brackets are at the very least unnecesary, may even be causing the problem. I also want to say ADODB has balked at me for having a semicolon at the end of my query


  • Re: Troubleshoot a INSERT INTO statement in Excel


    I ran it with Debug.Print thisSQL. Got a "Object Required" error


    Here are my Fields:
    ID, DateSub, DescSub, Sub, RunningTotal, Add, DescAdd, and DateAdd.
    Eight in total.
    Could someone show me where my syntax is Wrong.


    Code
    thisSQL = "INSERT INTO [a Chase Table] ([ID], [DateSub], [DescSub], [Sub], [RunningTotal], [Add], [DescAdd], [DateAdd]) VALUES (" & n & ", #" & Format(accDateSub, "yyyy/mm/dd") & "#, '" & accDescSub & "', " & accSub & ", " & accRunTotal & ", " & accAdd & ", '" & accDescAdd & "', #" & Format(accDateAdd, "yyyy/mm/dd") & "#);"


    Is it possible the syntax for the Dates are wrong?

  • Re: Troubleshoot a INSERT INTO statement in Excel


    It might not be the syntax, especially since you seem to have got rid of the square brackets, it could be the values.


    Hard to tell.


    What might help is knowing the error message you get when you try and execute the query.

    Boo!:yikes:

  • Re: Troubleshoot a INSERT INTO statement in Excel


    The error code is"


    Quote

    Run-time error'-2147217913(80040e07)':
    Syntax error in date in query expression'#'.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!