Results 1 to 11 of 11
  1. #1
    Join Date
    May 2004
    Posts
    159

    Unanswered: Is there a wait(x) function?

    Is there a wait so many seconds function in access? I suppose one could do a loop but computers are so fast now days that you don't know for sure how long it will take. I would like a simple wait for 5 seconds ability to pause the program then continue not wait forever expecting input.
    Thanks

  2. #2
    Join Date
    Sep 2003
    Location
    MN US
    Posts
    313
    Try VB help on "Timer Event". I believe that's what your looking for.

    HTH.

  3. #3
    Join Date
    Aug 2004
    Posts
    40
    Try this

    Code:
    Function Waitfor(Time As Integer, Showglass As Integer)
    
          Dim DelayEnd As Double
          DoCmd.Hourglass Showglass
          DelayEnd = DateAdd("s", Time, Now)
          While DateDiff("s", Now, DelayEnd) > 0
          Wend
          DoCmd.Hourglass False
          
    End Function
    Put an invisible field on your form and call it "Waiting" or something. Then call it by

    Code:
    Me!Waiting = Waitfor(3, -1)
    Where 3 is seconds and -1 is yes show the hourglass or 0 for don't.

    HTH

    hpicken

  4. #4
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    Here's my delay routine:

    [CODE]Public Function LoadingDelay(Optional ByVal DisplayDelayForm As Boolean = False)
    Dim StartTime As Date

    DoCmd.Hourglass True
    If DisplayDelayForm Then DoCmd.OpenForm "Loading"
    StartTime = Now
    Do While True
    DoEvents
    If DateDiff("s", StartTime, Now) > 5 Then Exit Do
    Loop
    If DisplayDelayForm Then DoCmd.Close acForm, "Loading"
    DoCmd.Hourglass False
    End Function
    [\CODE]
    Back to Access ... ADO is not the way to go for speed ...

  5. #5
    Join Date
    May 2004
    Posts
    159
    some interesting suggestions.. but I need it to be a public function that I can just call between running queries as I am finding they are running too fast and stepping on each other and giving wrong results. The previous code had msgbox's that one had to click to continue (30 of them!) and I want to automate that by just having a delay built in before running the next query.

    Something with the timer event looks like it would work. A sub that uses date(now) and times to an increment in seconds before returning..

  6. #6
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    Quote Originally Posted by WilliamS
    some interesting suggestions.. but I need it to be a public function that I can just call between running queries as I am finding they are running too fast and stepping on each other and giving wrong results. The previous code had msgbox's that one had to click to continue (30 of them!) and I want to automate that by just having a delay built in before running the next query.

    Something with the timer event looks like it would work. A sub that uses date(now) and times to an increment in seconds before returning..
    Well ... My routine, if you take out the openform calls does what you want ... You can mod it by passing in a value for the number of seconds to wait ...
    Back to Access ... ADO is not the way to go for speed ...

  7. #7
    Join Date
    Aug 2004
    Posts
    40
    And mine! You don't have to use the form field just call it between each query.

    Isn't it great that you have some options LOL.

  8. #8
    Join Date
    May 2004
    Posts
    159
    So what I need is something like this then! works for me thanks!
    [code]
    Public Sub waitfor(seconds As Integer)
    Dim StartTime As Date
    DoCmd.Hourglass True
    StartTime = Now
    Do While True
    If DateDiff("s", StartTime, Now) > seconds Then Exit Do
    Loop
    DoCmd.Hourglass False
    End Sub

  9. #9
    Join Date
    Apr 2004
    Location
    Sydney Australia
    Posts
    369
    This is the second or third time I have seen the problem mentioned that WilliamS is encountering.

    I have several macros that run a lot of queries, many of which depend on the previous query running but I have never had the problem.

    I use Access 95 and am wondering if it is a problem with the later versions. My computers are all the latest from Dell with the usual 2.5 to 3 GHerzx? of processor speed.

    Mike

  10. #10
    Join Date
    Aug 2004
    Posts
    40
    Yep if it does what you want it's fine.

    As for Mike375's comment, I've only found it a problem when using frontend and multi-user backend dbs. It took me a little while to work that when I first started with Access.

    Howard

  11. #11
    Join Date
    Jul 2004
    Posts
    17
    I'm having a similar problem. I have to send 38 emails at the same time. When I do it hangs my form very quickly.
    I'll try some these suggestions.
    thanks
    Code:
    For i = 0 To 37
        intDist = CInt(arDistNumbers(i))
        Call get_Address
        Call send_Report
    Next
    
    Private Sub send_Report()
    DoCmd.SendObject acSendQuery, "Dist" & intDist, acFormatHTML, address, , , "Missing Report", , False
    
    End Sub

Posting Permissions

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