Running a module at a certain time of the day

  • Thread starter Thread starter autolite
  • Start date Start date
A

autolite

I need to run a module at a specific time of the day every
day. I would like to automate this process with code.
Does anyone have ideas?
 
You can use a scheduling program like Arcana, SKEDEZY Or Launchpad to kick
off any executable at any time. Sometimes the built in scheduler actually
works too. (The AT scheduler in NT fails with linked ODBC tables though!)

You simply use a command line like:
"C:\Program Files\Office10\MSaccess.exe" "C:\mydocs\mydata.mdb" /x
"MacroName"

The Macro Name can call Runcode so you can execute just about anything you
can think of.
The last part of the macro should be Quit to exit Access.
 
I have used this in Excel. Excel must be active for this
to work. That is, this lives in an Excel macro that must
be active. Maybe it will work in Access.

Const timeToRun= "02:00:01" 'Time this will run each day
Dim runWhen As Double
runWhen = TimeValue(timeToRun)'When the processing sub
will run

' Each call to this only schedules the procedure once, so
need to call repeatedly
Sub StartTimer()
Application.OnTime earliesttime:=runWhen,
procedure:="processFiles" 'the sub that you want to run
End Sub

Sub StopTimer()
On Error Resume Next
Application.OnTime earliesttime:=runWhen,
procedure:="processFiles", Schedule:=False
End Sub
 
Back
Top