Form Timer help needed

RickK

Registered User.
Local time
Yesterday, 23:52
Joined
Oct 27, 2013
Messages
35
Currently I have a timer set on a form that runs in VBa and it looks to see if it is 6:00AM and if it is then it runs a DoCmd.

I want to change it to run every Monday at 6:00 AM and not everyday at 6:00AM . What do I need to add?

This is my current code:
Code:
Private Sub Form_Timer()
 If TimeValue(Now()) >= #6:00:00 AM# Then
        Dim stDocName As String

Thanks
Rick
 
the form is the timer, so inside the FORM_TIMER event, youd check for the time.
but if you only want it to run once, youd need a flag to prevent it from running until 6am runs out.

Code:
Private Sub Form_Timer()

if format(Now(),"hh:nn:ss") = #06:00:00# and format(date,"w") = vbMonday Then
    '  Run my code
endif
end sub
 
Personally I'd create a db that ran your process on startup and then quits, and call it from Scheduled Tasks. That way you don't have a timer event using resources, the process can't accidentally run twice on different computers, etc.
 

Users who are viewing this thread

Back
Top Bottom