Murray Brown
asked on
Access VBA - make timer run on each minute
Hi
I want my form timer event to run every five minutes on the minute. I achieved this is Visual Studio using
Me.Timer1.Interval = New TimeSpan(Now.Hour, Now.Minute + 1, 0).Subtract(Now.TimeOfDay) .TotalMill iseconds
How would I do the equivalent in Access VBA
Me.TimerInterval = ???????
I want my form timer event to run every five minutes on the minute. I achieved this is Visual Studio using
Me.Timer1.Interval = New TimeSpan(Now.Hour, Now.Minute + 1, 0).Subtract(Now.TimeOfDay)
How would I do the equivalent in Access VBA
Me.TimerInterval = ???????
ASKER
Hi
Thanks for that but that doresn't answer my question. If I open my database at 08:50:33 (8:50 and 33 seconds) I want it to run next at 08:55:00 and then at 09:00:00
So the first time the timer runs is on the exact minute
Thanks for that but that doresn't answer my question. If I open my database at 08:50:33 (8:50 and 33 seconds) I want it to run next at 08:55:00 and then at 09:00:00
So the first time the timer runs is on the exact minute
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks
Pete,
So basically your code checks to see if time is divisible by 5 minutes with no remainder?
So basically your code checks to see if time is divisible by 5 minutes with no remainder?
Not exactly.
If it's not the first time through the timerinterval is set to 5 minutes.
If it is first time through the timer interval is set to the remaining time until the next 5 minute value.
If it's not the first time through the timerinterval is set to 5 minutes.
If it is first time through the timer interval is set to the remaining time until the next 5 minute value.
ASKER
To clarify...I wanted the timer to run at the beginning of each minute. Because the user can open the app at any point, the first interval is the remainder, eg if the time is 08:02:30 then there are two and a half minutes left to the next 5 minute point. What I did was set the timer to the remainder and then when the timer is run, set the interval to 300000 milliseconds or 5 mins
mx