Results 1 to 4 of 4

Thread: pause execution

  1. #1
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    austin, Texas, USA
    Posts
    1,029
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I am trying to simulate a long-running process in the course of developing the UI. what i'd like to do is just set Access to pause for a while. what i've ginned up is this:

    If Response = vbOK Then
    Me.lblWarning.Visible = True
    Me.btnProcessSample.Enabled = False
    DoCmd.Hourglass True
    End If

    If Response = vbOK Then
    For i = 0 To 10000
    Debug.Print i
    Next i
    Application.Quit
    End If

    which does kind of work, but the command to set the label text to visible doesn't happen until the loop is done, which is annoying. The button disables and mr. Hourglass appears, but label just doesn't appear. Weird!!

    i'm not all that thrilled about a loop that does debug.print just to simulate activity, but i am a little confused on what would be a better solution.

    Any ideas?

    TIA

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    To force the label to become visible, try

    Me.Repaint

    (assuming the code is in the form module)

    If you want a short pause, you could try

    Code:
    For i = 1 To 1000
      DoEvents
    Loop
    or similar. DoEvents yields the processor to other processes, so it's better than Debug.Print or similar.

  3. #3
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    austin, Texas, USA
    Posts
    1,029
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks! Me.Repaint did it.

    for the pause function i did this:

    Dim T1 As Variant
    Dim T2 As Variant

    T1 = Now()
    T2 = DateAdd("s", 5, T1)

    Do Until T2 <= T1
    T1 = Now()
    Loop

    which has the advantage of specifying how many seconds to do that pause.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    I'd insert DoEvents in the loop, so that Access doesn't hog the processor all the time:

    Code:
    	Do Until T2 <= T1
    		DoEvents
    		T1 = Now()
    	Loop

Posting Permissions

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