How to Run a procedure on a schedule

VSolano

Registered User.
Local time
Today, 09:13
Joined
Feb 21, 2017
Messages
92
I would like some guidance on running a procedure or function base on schedule. Something like first day of the month or the 15 of the month
 
Should be easy enough, at startup have your application determine the date and if it is correct, run the procedure.
 
I have a VBScript open Access database and run procedure even when I am not around. Use text editor (Notepad works) and rename with .vbs extension.

Windows TaskScheduler runs VBAScript file. Computer must be on.

Here is example script showing several ways to manipulate Access:
Code:
Set accessApp = GetObject("Access.Application")
accessApp.OpenCurrentDataBase "C:\Users\June\Forums\recur2.mdb"
accessApp.UserControl = False
accessApp.Visible = False
accessApp.Run "TestVBA"
accessApp.DoCmd.RunMacro "TestMacro"
accessApp.Quit

Set cn = CreateObject("ADODB.Connection")
cn.open = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source=C:\Users\June\LL\Umpires.accdb"
cn.execute "INSERT INTO Rates(RateID,RateLevel) VALUES('zz','zz')"
cn.Close

Dim db
Dim strFilePath
strFilePath = WScript.Arguments(0)
MsgBox strFilepath
set db = GetObject("C:\Users\June\Forums\recur2.mdb")
db.quit
set db = Nothing
 
Last edited:
The issue with this is if the application does not start on the schedule what will happen to the procedure
 
Set Task Scheduler to open your database and run a macro which calls your procedure.
The task scheduler settings can include waking the computer if in hibernation.
However it can't turn on a computer that is switched off.

If that is likely, then add a logging event to your procedure to check whether its already been completed. Next modify the macro to run the procedure if not already done but exit if already done. Modify your task scheduler actions to open your database and run the macro at repeated intervals to ensure it does run once and once only.
 
Last edited:
The issue with this is if the application does not start on the schedule what will happen to the procedure
Hi. As Colin suggested, you could log when a procedure has ran, so you can tell if it hasn't. Cheers!
 

Users who are viewing this thread

Back
Top Bottom