Form Timer help needed (1 Viewer)

RickK

Registered User.
Local time
Today, 01:35
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
 

Ranman256

Well-known member
Local time
Today, 04:35
Joined
Apr 9, 2015
Messages
4,337
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
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 01:35
Joined
Aug 30, 2003
Messages
36,125
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

Top Bottom