+ Reply to Thread
Results 1 to 3 of 3

Troubleshooting syntax error

  1. #1
    Forum Contributor
    Join Date
    03-08-2011
    Location
    Lubbock, TX, USA
    MS-Off Ver
    MS OFFICE 365 EXCEL, OUTLOOK, WORD, POWERPOINT
    Posts
    196

    Troubleshooting syntax error

    Hi. I am trying to import from an SQL database that I have limited access to. It's a replicated database and we are allowed to take data from it and put into excel to manipulate or research etc.

    The error is:

    Screenshot 2021-05-14 161939.png

    The last line above is what is highlighted by the debugger. Hovering the cursor over the first part will popup the line. I've attached screenshots of the error and the debug clue.

    Screenshot 2021-05-14 162136.pngThen it continues.

    I'm not a programmer but I'm ok at learning and reading and adapting. I don't see any obvious errors. I know the sql will run without the VBA modifications on the companies sql server. I know all the calls and such work.

    I tried pasting the code in between the code and /code bracket tags and on previewing it said I was blocked for an sql injection. If someone can tell me what I did wrong i will be happy to post the code for review.

  2. #2
    Forum Expert
    Join Date
    07-06-2004
    Location
    Northern California
    MS-Off Ver
    2K, 2003, 2010, O365
    Posts
    1,490

    Re: Troubleshooting syntax error

    Per the documentation, the 1st positional argument to ADODB.Recordset.Open must be 'A Variant that evaluates to a valid Command object, an SQL statement, a table name, a stored procedure call, a URL, or the name of a file or Stream object containing a persistently stored Recordset.' "WO.RESOLUTIONDATE desc" isn't a valid SQL statement, a valid table name, or a URL, nor I figure is it the valid name of a file or stream object containing . . . That leaves the possibility it's a stored procedure call with the parameter desc. You don't show enough code for me to tell what it's supposed to be.

  3. #3
    Forum Contributor
    Join Date
    03-08-2011
    Location
    Lubbock, TX, USA
    MS-Off Ver
    MS OFFICE 365 EXCEL, OUTLOOK, WORD, POWERPOINT
    Posts
    196

    Re: Troubleshooting syntax error

    I've no idea why the board will not allow me to post the code. Like I said, I had it pasted in the code tags but it still blocked me. I will look at the code again on Monday. But I bet there is an order by statement and I might have truncd the line. DESC is short for decending. That's what makes me bet that way. Thanks for the pointer.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Compile error syntax error - spellnumber microsoft code
    By sunboy in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 12-13-2022, 02:53 AM
  2. Floor Plan Macro - Need help troubleshooting 'Run time error 9' error message
    By liddy in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-16-2021, 03:23 AM
  3. [SOLVED] Runtime Error '3075': Syntax error in the string in the query expression [SQL]
    By leegrj in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 05-28-2020, 04:11 PM
  4. Replies: 5
    Last Post: 11-28-2019, 04:55 AM
  5. Excel macro (compile error. syntax error.) error
    By salar_younis in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-06-2014, 06:11 AM
  6. Receiving following error “Complie error : syntax error” Help
    By masond3 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-02-2012, 10:19 AM
  7. Syntax Error and Compile Error: Expected Line Number or Label...
    By AnthonyWB in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-31-2011, 09:59 AM

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