I agree with using a timer control, but not in the part about setting the interval because the process you want to run might take widely varying amounts of time in each instance, due to factors such as IPL (initial program load), LAN traffic, etc.
I prefer to set an interval at, say, 500, and write code that tests a variable reflecting latest completion time.
In the example below, I use the Timer control AND the Timer Property of the VBA.DateTime class (which, in addition to its splendid accuracy, uses seconds as the default interval so that you don't have to mess around with DateDiff syntax)
Option Explicit
Public lastCompletionTime As Single
Const SecondsInterval As Integer = 3
Private Sub Timer1_Timer()
If Timer > lastCompletionTime + SecondsInterval Then
'We need to run our process
'Do something here
'Do something here
'Do something here
'Do something here
'When that something is done,
'reset the time
lastCompletionTime = Timer
'This line of code was just my way of demonstrating that
'my code runs only at the desired intervals
Me.Caption = Time$
End If
End Sub
Main Topics
Browse All Topics





by: olivboyPosted on 2003-06-09 at 06:20:52ID: 8681590
Use a Timer control end set its interval at 30000