I need a wait() function

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • MrDeej
    New Member
    • Apr 2007
    • 157

    I need a wait() function

    Hello guys!

    I am trying to use trevors wait function on my odbc database for a countdown function. But this function is not stable as it sometimes dosent actually wait before launching next line of code

    The database is a ODBC update database which is full automatic startup/shutdown but because i sometimes want to make som edits to it i want a countdown before it shutsdown with a "cancel shutdown" code.

    Code:
    Wait(1)
    me.etk_information.caption = "Shutdown in 5 seconds....
    Wait (1)
    me.etk_information.caption = "Shutdown in 4 seconds....
    Wait (1)
    me.etk_information.caption = "Shutdown in 3 seconds....
    Wait (1)
    me.etk_information.caption = "Shutdown in 2 seconds....
    Wait (1)
    me.etk_information.caption = "Shutdown in 1 seconds....
    Wait (1)
    Docmd.quit
    and some more lines of code to abort shutdown..
    But because the wait function isnt working properly it sometimes just flyes through all the code without waiting and my shutdown sequense is wasted
  • pks00
    Recognized Expert Contributor
    • Oct 2006
    • 280

    #2
    trevor's wait function eh, whose trevor?

    what about the use of a api function like sleep

    add this to a module
    then call this SleepPls passing in 1 for 1second obviously!!!


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

    Public Sub SleepPls(ByVal lSecs As Long)
    Sleep (lSecs * 1000)
    End Sub

    Comment

    • ADezii
      Recognized Expert Expert
      • Apr 2006
      • 8834

      #3
      Originally posted by MrDeej
      Hello guys!

      I am trying to use trevors wait function on my odbc database for a countdown function. But this function is not stable as it sometimes dosent actually wait before launching next line of code

      The database is a ODBC update database which is full automatic startup/shutdown but because i sometimes want to make som edits to it i want a countdown before it shutsdown with a "cancel shutdown" code.

      Code:
      Wait(1)
      me.etk_information.caption = "Shutdown in 5 seconds....
      Wait (1)
      me.etk_information.caption = "Shutdown in 4 seconds....
      Wait (1)
      me.etk_information.caption = "Shutdown in 3 seconds....
      Wait (1)
      me.etk_information.caption = "Shutdown in 2 seconds....
      Wait (1)
      me.etk_information.caption = "Shutdown in 1 seconds....
      Wait (1)
      Docmd.quit
      and some more lines of code to abort shutdown..
      But because the wait function isnt working properly it sometimes just flyes through all the code without waiting and my shutdown sequense is wasted
      In the Declarations Section of a Standard Code Module:
      Code:
      Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
      Wherever appropriate:
      Code:
      Dim intCounter As Integer
      
      Me![txtTest] = ""
      
      For intCounter = 5 To 1 Step -1
        Me![txtTest] = "Shutdown in " & intCounter & " seconds..."
        Sleep (1000)
         DoEvents
      Next

      Comment

      • MrDeej
        New Member
        • Apr 2007
        • 157

        #4
        Thank you guys!
        Now it is working :)

        Comment

        • ADezii
          Recognized Expert Expert
          • Apr 2006
          • 8834

          #5
          Originally posted by MrDeej
          Thank you guys!
          Now it is working :)
          You're welcome.

          Comment

          Working...