Consulting

Results 1 to 3 of 3

Thread: Cancel querytable.refresh

  1. #1

    Cancel querytable.refresh

    Hi,
    my querytable refreshes its data from external source and then rest of the code is executed:

    .ListObjects(1).QueryTable.Refresh BackgroundQuery:=False
    ' ... rest of the code
    This way the rest of code waits until refresh is finished.
    However I'd like to be able to cancel the refresh.

    I tried with
     BackgroundQuery:=True
    , this gave me option in statusbar to cancel it but rest of the code is run immediately without waiting.
    Following:
     Application.CalculateUntilAsyncQueriesDone
    let the rest of code wait but then I loose the option in statusbar to cancel.
    Also I tried to launch a modeless form with button which onClick would execute
     .ListObjects(1).QueryTable.CancelRefresh
    , but the form shows without button and inactive.

    Can someone please advise ?

  2. #2
    Still no tips ? Anything not clear about question ?

  3. #3
    VBAX Master Aflatoon's Avatar
    Joined
    Sep 2009
    Location
    UK
    Posts
    1,720
    Location
    You'd need to use a class module to hook into the events of the querytable, and then call the rest of the code from the AfterRefresh event, assuming it was successful. I answered a similar question here, which has sample code: https://stackoverflow.com/questions/...button-pressed
    Be as you wish to seem

Posting Permissions

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