Forcing Wait or Delay ?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • SheldonMopes@KidNet.com

    #1

    Forcing Wait or Delay ?

    Is there a way to force Access to pause execution for a specified
    period of time ? I would like a command button on a form to run it's
    code when clicked and then pause for 2 seconds before allowing any
    other user input. Thank you for any help.

  • Wayne Gillespie

    #2
    Re: Forcing Wait or Delay ?

    On Sun, 05 Feb 2006 03:54:30 GMT, SheldonMopes@Ki dNet.com wrote:
    [color=blue]
    >Is there a way to force Access to pause execution for a specified
    >period of time ? I would like a command button on a form to run it's
    >code when clicked and then pause for 2 seconds before allowing any
    >other user input. Thank you for any help.[/color]

    Put the following into your code where you want the pause.

    Dim T1 As Variant
    Dim T2 As Variant

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

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


    Wayne Gillespie
    Gosford NSW Australia

    Comment

    • mike noel

      #3
      Re: Forcing Wait or Delay ?

      You could use windows api stuff...


      Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

      ....

      Sleep 2000



      SheldonMopes@Ki dNet.com wrote:[color=blue]
      > Is there a way to force Access to pause execution for a specified
      > period of time ? I would like a command button on a form to run it's
      > code when clicked and then pause for 2 seconds before allowing any
      > other user input. Thank you for any help.
      >[/color]

      Comment

      • teddysnips@hotmail.com

        #4
        Re: Forcing Wait or Delay ?


        Wayne Gillespie wrote:[color=blue]
        > On Sun, 05 Feb 2006 03:54:30 GMT, SheldonMopes@Ki dNet.com wrote:
        >[color=green]
        > >Is there a way to force Access to pause execution for a specified
        > >period of time ? I would like a command button on a form to run it's
        > >code when clicked and then pause for 2 seconds before allowing any
        > >other user input. Thank you for any help.[/color]
        >
        > Put the following into your code where you want the pause.
        >
        > Dim T1 As Variant
        > Dim T2 As Variant
        >
        > T1 = Now()
        > T2 = DateAdd("s", 2, T1)
        >
        > Do Until T2 <= T1
        > T1 = Now()
        > Loop[/color]

        If you're going to wait for an appreciable length of time, you might
        want to put a DoEvents in the loop.

        Edward

        Comment

        • Jeremy Wallace

          #5
          Re: Forcing Wait or Delay ?

          I use Trevor Best's code:
          Sub WaitFor(psngSec onds As Single)
          ' wait for specified number of seconds
          ' Copyright Trevor Best (tre...@besty.o rg.uk) <-OK, so I added
          thisline.

          Dim sngStart As Single
          Dim sngET As Single

          sngStart = Timer
          DoEvents
          Do While sngET < psngSeconds
          DoEvents
          ' check for mighnight as the Timer() function will
          ' rollover at this point
          sngET = Timer - sngStart
          If sngET < 0 Then
          ' it rolled over - add number of seconds
          ' in a day
          sngET = sngET + 86400
          Beep
          End If
          ' now don't hog the processor
          ' release some CPU slices back to Windoze
          DoEvents
          Loop

          End Sub

          Comment

          Working...