Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run Code At the Same time every day

Status
Not open for further replies.

ptiernan

IS-IT--Management
Apr 29, 2003
55
GB
Hi could anyone give me some ideas on how I can run some code at a certain time for example 4 am every work day Mon – Fri.

One option I have thought of is have single form Access DB constantly running and an On Timer event running the code.
 
If you choose to go with the On Timer event in Access
you would need to do something like this in a module -

Public Function Access_Cron()
Weekday
If Weekday(Now()) And CStr(Time()) = "7:51:00 PM" Then
MsgBox "Time is 8PM EST"
End If
End Function


In the On Timer you would mere need to have the function call Access_Cron and the Timer Interval set to what you desired 1000 equal 1 second.


HTH,

Steve


 
Oh, and yes I do realize that the time value and the message box are off, but that is why QA is needed.

[rednose] <-- So many clowns like me and so few circuses.

I hope the example helps.

Steve
 
Thanks for that Steve but is there not a more elegant way of archiving this result as your code runs every second.

 
Ptiernan,


Of course if you wish to have the check happen hourly then you would just need to adjust the Timer Interval.

For an hour it would be 3600000.

:)


Steve
 
Not sure what operating system you are using, but you can run a scheduled task. from the Start Bar:

Start, Programs, Accessories, System Tools, Scheduled Tasks, Add Scheduled Task; then follow the prompts of the wizard. If you wanted to trigger an Access program, they you'd have to set up the command line parameters / autoexec appropriately; alternatively, depending on what it is you're tyring to do, a simple DOS batch file; VB executable or whatever could be options.

Just thought I'd provide this as an alternative option, where you dont need to make sure that Access and the OnTimer event are ticking over at the time.





Steve Lewy
Solutions Developer
steve@lewycomputing.com.au
(dont cut corners or you'll go round in circles)
 
I'll second Steve's offering, but add that if you have admin rights on your PC, you can set up the scheduled task to run, even if you are not logged in, useful for those overnight jobs.

Ben

----------------------------------------------
Ben O'Hara &quot;Where are all the stupid people from...
...And how'd they get so dumb?&quot;
rockband.gif
NoFX-The Decline
----------------------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top