Timing loop

GeoNelix

Registered User.
Local time
Today, 14:53
Joined
Aug 27, 2002
Messages
30
Good Morning!
I need to develop a timing loop. The loop needs to run for approximately 5 seconds. Any ideas? I'm using Access 2000...
 
Are you just trying to set a pause for 5 seconds? I use this to pause my db so that certain commands can catch up like updating a label after a query or transfer has completed and before the next transfer begins...

Public Function Pause(NumberOfSeconds As Variant)
On Error GoTo Err_Pause

Dim PauseTime As Variant, Start As Variant

PauseTime = NumberOfSeconds
Start = Timer
Do While Timer < Start + PauseTime
DoEvents
Loop

Exit_Pause:
Exit Function

Err_Pause:
Msg Err.Number, Err.Description
Resume Exit_Pause

End Function

To call the pause in your code, just type Pause (x) on a new line. Replace the x with the number of seconds you want to pause.

Pause (5) 'five second pause

HTH
 
I'm looping through a set of microsoft word documents in a local file. For each document in the loop I am printing, then closing the active window without saving changes. In each case I am checking the background print property before closing the active doc window. The problem is that my code is not giving word enough time to quit the active doc window and ready itself for the next document. When I insert message boxes inside the code to see where it stalls the process works fine. So I figured why not use a timing loop that runs for about 5 seconds in place of the message boxes? Or is there another solution? This is my code:

If Not rs.EOF Then
rs.MoveFirst
Dim wordObj As Object
Set wordObj = CreateObject("Word.Application")
Do While Not rs.EOF
vName = GetFileName(rs("StdEndorsementTypeID"))
If vName <> "" Then
Path = "C:\StandardEndorsements\" & vName

wordObj.Documents.Open Path
wordObj.PrintOut

tmpCheck = False
Do Until tmpCheck
If wordObj.BackgroundPrintingStatus = 0 Then
tmpCheck = True
End If
Loop

wordObj.ActiveDocument.Close SaveChanges:=
wdDoNotSaveChanges

rs.MoveNext
Loop
wordObj.Quit

End If
 
Sounds like the DoEvents function might be what you need. Check the help files for the DoEvents Function for more info and examples.

HTH
 

Users who are viewing this thread

Back
Top Bottom