+ Reply to Thread
Results 1 to 3 of 3

VBA to wait for query to finish before starting next query in a sql refresh link

  1. #1
    Registered User
    Join Date
    10-09-2016
    Location
    Preston, England
    MS-Off Ver
    2010, 2013 & 2016
    Posts
    30

    Question VBA to wait for query to finish before starting next query in a sql refresh link

    Hello all,

    This might be a quick and easy one for some of you. I have a Macro created that refreshes two tables (these are connected to a view in SQL).
    When we use the refresh all function we get a time out in sql as it tries to refresh the tables at the same time.

    we are after some vba code to fit imbertween the three refresh codes (below) that force the macro to wait for each refresh to be completed before it starts the next. Simply put the three refreshes need to happen in a sequence and not at once.

    Any help on this is greatly appreciated

    Please Login or Register  to view this content.
    Last edited by Jwilf; 01-24-2017 at 08:43 AM.

  2. #2
    Valued Forum Contributor
    Join Date
    03-24-2014
    Location
    England
    MS-Off Ver
    Excel 2003 - 2016
    Posts
    575

    Re: VBA to wait for query to finish before starting next query in a sql refresh link

    Put

    Please Login or Register  to view this content.
    just after the refresh commands.


    Edit: Oh and check the excel data connections properties and make sure 'background refresh' is not ticked in there.

  3. #3
    Registered User
    Join Date
    10-09-2016
    Location
    Preston, England
    MS-Off Ver
    2010, 2013 & 2016
    Posts
    30

    Re: VBA to wait for query to finish before starting next query in a sql refresh link

    Thank you so much for that.

    Its made a big difference

+ 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. SQL connections, wait with the code until query is done!
    By Reemet in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-14-2015, 02:38 AM
  2. Refresh all query & save. not enough time for query to complete.
    By mortphil in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-08-2015, 04:26 AM
  3. Problem with selecting range with in query table after query refresh
    By shooter in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-31-2012, 11:55 AM
  4. Macro to Wait for Query to Run
    By SP Brian in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 03-16-2010, 06:40 PM
  5. Excel paste link changes after sql query refresh
    By dest in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 07-08-2008, 03:41 PM
  6. Pausing a macro to wait for the results from the query
    By ldevrries in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-19-2007, 10:55 AM
  7. [SOLVED] Link Access query to refresh an EXCEL file
    By Dancer4u in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 01-13-2005, 02:06 PM

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