• Pausing a Macro (2000)

    Author
    Topic
    #388948

    The very first thing my macro does is refresh all of the MS Queries using RefreshAll but while it is refreshing the macro continues on. How do I get it to wait until the refreshing is finished before continuing? I tried the “Wait” method but that pauses the refreshing as well.

    Viewing 1 reply thread
    Author
    Replies
    • #685235

      Insert this function in your module and call it any time it’s needed. It pauses continuation of the code for the number of seconds you stipulate. I originally took it from am old Winfax code in Word and now use it quite a bit.
      Function Pause(ByVal nSecond As Single)
      Dim t0 As Single
      t0 = Timer
      Do While Timer – t0 < nSecond
      Dim dummy As Integer
      dummy = DoEvents()
      If Timer < t0 Then t0 = t0 – 24 * 60 * 60 ' if we cross midnight, back up one day
      Loop
      End Function

      Peter

    • #685395

      It may cause less overhead to set the BackgroundQuery property to false for those queries.
      AFAIK you then do not need the timer (not tested).

    Viewing 1 reply thread
    Reply To: Pausing a Macro (2000)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: