Here are some ways to time things out in VB.
In this instance the program will not run until after 7 AM.
Do
If Time > #7:00:00 AM# Then
MsgBox ("Time is " & Time)
Exit Do
End If
Loop
This one simply delays a process for a set amount of time. This example would delay the process for 1 asecond. I am pulling it off the top of my head so it might not be exact.
Application.wai tnow + (timevalue("00: 00:01"))
There is also the timer function from Excel Help that can be used in Access with minor modifications.
This example uses the Timer function to pause the application. The example also uses DoEvents to yield to other processes during the pause.
Dim PauseTime, Start, Finish, TotalTime
If (MsgBox("Press Yes to pause for 5 seconds", 4)) = vbYes Then
PauseTime = 5 ' Set duration.
Start = Timer ' Set start time.
Do While Timer < Start + PauseTime
DoEvents ' Yield to other processes.
Loop
Finish = Timer ' Set end time.
TotalTime = Finish - Start ' Calculate total time.
MsgBox "Paused for " & TotalTime & " seconds"
Else
End
End If
And one last timer function for VBA taken from http://msdn2.microsoft .com/en-us/library/aa211461(office .11).aspx
Private Sub Form_Timer()
Clock.Caption = Time ' Update time display.
End Sub
In this instance the program will not run until after 7 AM.
Do
If Time > #7:00:00 AM# Then
MsgBox ("Time is " & Time)
Exit Do
End If
Loop
This one simply delays a process for a set amount of time. This example would delay the process for 1 asecond. I am pulling it off the top of my head so it might not be exact.
Application.wai tnow + (timevalue("00: 00:01"))
There is also the timer function from Excel Help that can be used in Access with minor modifications.
This example uses the Timer function to pause the application. The example also uses DoEvents to yield to other processes during the pause.
Dim PauseTime, Start, Finish, TotalTime
If (MsgBox("Press Yes to pause for 5 seconds", 4)) = vbYes Then
PauseTime = 5 ' Set duration.
Start = Timer ' Set start time.
Do While Timer < Start + PauseTime
DoEvents ' Yield to other processes.
Loop
Finish = Timer ' Set end time.
TotalTime = Finish - Start ' Calculate total time.
MsgBox "Paused for " & TotalTime & " seconds"
Else
End
End If
And one last timer function for VBA taken from http://msdn2.microsoft .com/en-us/library/aa211461(office .11).aspx
Private Sub Form_Timer()
Clock.Caption = Time ' Update time display.
End Sub
Comment