SLEEP or

  • Thread starter Thread starter ted medin
  • Start date Start date
T

ted medin

Notice when i use Doevents in a loop waiting for the user to view/... a
print the cpu time goes way up. Looks like Sleep(1000) in the loop would
really give up the cpu. So how does one really give up the cpu for a
second or so. Or is there a better way to do this? TIA
 
Need help on how to enter this into my vba code. I get compile error about
the 'private declare ...'

tried using 'sleep(1000)' but its an unknown function/sub

'***************** Code Start *******************
' This code was originally written by Dev Ashish.
' It is not to be altered or distributed,
' except as part of an application.
' You are free to use it in any application,
' provided the copyright notice is left unchanged.
'
' Code Courtesy of
' Dev Ashish
'
Private Declare Sub sapiSleep Lib "kernel32" _
Alias "Sleep" _
(ByVal dwMilliseconds As Long)

Sub sSleep(lngMilliSec As Long)
If lngMilliSec > 0 Then
Call sapiSleep(lngMilliSec)
End If
End Sub

Sub sTestSleep()
Const cTIME = 1000 'in MilliSeconds
Call sSleep(cTIME)
MsgBox "Before this Msgbox, I was asleep for " _
& cTIME & " Milliseconds."
End Sub
'***************** Code End *********************

Check http://www.mvps.org/access/api/api0021.htm at "The Access Web"
 
Where have you put the code?

Create a new module (not a class module nor a module associated with a form
or report) and paste the code into it.
 
Back
Top