By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,572 Members | 963 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,572 IT Pros & Developers. It's quick & easy.

I need a wait() function

100+
P: 157
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.

Expand|Select|Wrap|Line Numbers
  1. Wait(1)
  2. me.etk_information.caption = "Shutdown in 5 seconds....
  3. Wait (1)
  4. me.etk_information.caption = "Shutdown in 4 seconds....
  5. Wait (1)
  6. me.etk_information.caption = "Shutdown in 3 seconds....
  7. Wait (1)
  8. me.etk_information.caption = "Shutdown in 2 seconds....
  9. Wait (1)
  10. me.etk_information.caption = "Shutdown in 1 seconds....
  11. Wait (1)
  12. Docmd.quit
  13.  
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
Apr 21 '07 #1
Share this Question
Share on Google+
4 Replies


pks00
Expert 100+
P: 280
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
Apr 21 '07 #2

ADezii
Expert 5K+
P: 8,632
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.

Expand|Select|Wrap|Line Numbers
  1. Wait(1)
  2. me.etk_information.caption = "Shutdown in 5 seconds....
  3. Wait (1)
  4. me.etk_information.caption = "Shutdown in 4 seconds....
  5. Wait (1)
  6. me.etk_information.caption = "Shutdown in 3 seconds....
  7. Wait (1)
  8. me.etk_information.caption = "Shutdown in 2 seconds....
  9. Wait (1)
  10. me.etk_information.caption = "Shutdown in 1 seconds....
  11. Wait (1)
  12. Docmd.quit
  13.  
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:
Expand|Select|Wrap|Line Numbers
  1. Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Wherever appropriate:
Expand|Select|Wrap|Line Numbers
  1. Dim intCounter As Integer
  2.  
  3. Me![txtTest] = ""
  4.  
  5. For intCounter = 5 To 1 Step -1
  6.   Me![txtTest] = "Shutdown in " & intCounter & " seconds..."
  7.   Sleep (1000)
  8.    DoEvents
  9. Next
Apr 21 '07 #3

100+
P: 157
Thank you guys!
Now it is working :)
Apr 23 '07 #4

ADezii
Expert 5K+
P: 8,632
Thank you guys!
Now it is working :)
You're welcome.
Apr 23 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.