+ Reply to Thread
Results 1 to 12 of 12

Run-Time Error When SQL Runs

  1. #1
    Registered User
    Join Date
    11-26-2014
    Location
    London
    MS-Off Ver
    2013
    Posts
    95

    Run-Time Error When SQL Runs

    Hi I am trying to run the following code. When I Step-through the code it gets to the 'End Function' I get the following message 'Run-time error - Object doesn't support this property or method'


    I have similar code that is working fine. It is just this particular one where the error is?

    When i copy the Debug.Print SQL_STRING in to SQL the SQL part of the code works.

    Am I missing something on the VBA side?


    Please Login or Register  to view this content.

  2. #2
    Valued Forum Contributor kasan's Avatar
    Join Date
    07-22-2009
    Location
    Riga, Latvia
    MS-Off Ver
    Excel 2010
    Posts
    680

    Re: Run-Time Error When SQL Runs

    Edit: Sorry, misread real question.
    Tested your code on my connection - works fine.
    Last edited by kasan; 12-23-2016 at 07:37 AM.

  3. #3
    Registered User
    Join Date
    11-26-2014
    Location
    London
    MS-Off Ver
    2013
    Posts
    95

    Re: Run-Time Error When SQL Runs

    Would you know why I get this error? I just copied the exact code above and i still get the error. 'Run-time error 438 - Object doesn't support this property or method'

    It runs the code fine, but when I look at this by Stepping-Into the code the error appears once I have stepped through the code and the current step is on 'End Function' (highlighted yellow)?

    So appears something might be wrong with the way it is trying to exit on End Function?

  4. #4
    Valued Forum Contributor kasan's Avatar
    Join Date
    07-22-2009
    Location
    Riga, Latvia
    MS-Off Ver
    Excel 2010
    Posts
    680

    Re: Run-Time Error When SQL Runs

    Have no idea, really. Did you try to run your code under Sub () (not function)?

  5. #5
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Run-Time Error When SQL Runs

    How are you calling this function?
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  6. #6
    Registered User
    Join Date
    11-26-2014
    Location
    London
    MS-Off Ver
    2013
    Posts
    95

    Re: Run-Time Error When SQL Runs

    I Kasan

    I have fixed the error. For some unknown reason the code didnt like the Function. I just moved this code into the main part of my coding on the userform and it works.

  7. #7
    Registered User
    Join Date
    11-26-2014
    Location
    London
    MS-Off Ver
    2013
    Posts
    95

    Re: Run-Time Error When SQL Runs

    Hi xlnitwit I call all my function like this Application.Run Module1.ELTTables It works for all the others, just this one.

  8. #8
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Run-Time Error When SQL Runs

    That is not the same function name?

  9. #9
    Registered User
    Join Date
    11-26-2014
    Location
    London
    MS-Off Ver
    2013
    Posts
    95

    Re: Run-Time Error When SQL Runs

    Sorry, I know I was just giving an example of the structure I use. It call the Function fine and runs through it. Its was just the Exiting of the Function

  10. #10
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Run-Time Error When SQL Runs

    My assumption is that something was wrong at the calling end since the function itself runs properly. Unless we can see the actual caller it's hard to verify though.

  11. #11
    Registered User
    Join Date
    11-26-2014
    Location
    London
    MS-Off Ver
    2013
    Posts
    95

    Re: Run-Time Error When SQL Runs

    Agh it was that. So silly. I wrote Rum instead of RUN.

  12. #12
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Run-Time Error When SQL Runs

    I assume you know that Run takes a routine name so its argument should be in quotes
    Please Login or Register  to view this content.

+ 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] This macro runs fine the first time, but generates a Type Mismatch error after that.
    By armlegx in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-05-2016, 01:46 PM
  2. vba code throws an error first time but runs perfectly the second time. HELP!!
    By mvneema in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-29-2014, 12:42 PM
  3. [SOLVED] On error runs for first time only
    By navwelch in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-19-2013, 06:54 AM
  4. Error when running macro at a specific time: only runs once
    By Axildoofay in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-09-2013, 05:54 AM
  5. [SOLVED] Range error in code, runs alone but not inside my full program, giving runtime error 1004
    By charizzardd in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-23-2012, 03:34 PM
  6. Replies: 3
    Last Post: 03-29-2012, 01:58 PM
  7. Run-time Error 9 with Excel macro - Runs in 2003, Fails in 2007
    By jialant in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-05-2008, 09:37 AM

Tags for this Thread

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