Run procedure at specific time
I have an application that runs 24/7 and there is a procedure in that project that can be run by the press of a button. However, it needs to be pushed at 7AM every morning and I want to automate that process (running the procedure).
I've throught about setting up a timer, but that has to check every minute for the time. Then I thought about splitting the procedure out into a small second app, but that complicates the installation elsewhere.
Does anyone know of a good way to do this?
Re: Run procedure at specific time
use a timer... nothing wrong with that.. used to do it all the time with access
set the timer interval to 30000 (30 seconds) or 60000(1 minute)
then test if the time > #7:00:00 AM# ....
Re: Run procedure at specific time
Ok... but every minute after 7AM, that's going to run. How do I only get it to run once? I'd have to set it so that if it's 7:00 and not worry about the seconds.
Re: Run procedure at specific time
well.. u cant set it to be
if time = 7.. cause there is the chance it will miss the exact time and not run
try somethinglike this...
you need to track the day and if it has run....
VB Code:
Dim currDate As Date
Dim RanIt As Boolean
Private Sub Form_Load()
currDate = Date
End Sub
Private Sub Timer1_Timer()
If currDate <> Date Then
RanIt = False
currDate = Date
End If
If Time > #7:00:00 AM# And Not RanIt Then
RanIt = True
'RUN CODE
End If
End Sub