How to Run a procedure on a schedule (1 Viewer)

VSolano

Registered User.
Local time
Today, 04:22
Joined
Feb 21, 2017
Messages
85
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
 

NauticalGent

Ignore List Poster Boy
Local time
Today, 04:22
Joined
Apr 27, 2015
Messages
6,319
Should be easy enough, at startup have your application determine the date and if it is correct, run the procedure.
 

June7

AWF VIP
Local time
Today, 00:22
Joined
Mar 9, 2014
Messages
5,463
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:

VSolano

Registered User.
Local time
Today, 04:22
Joined
Feb 21, 2017
Messages
85
The issue with this is if the application does not start on the schedule what will happen to the procedure
 

Gasman

Enthusiastic Amateur
Local time
Today, 09:22
Joined
Sep 21, 2011
Messages
14,223
Use the task scheduler?
 

isladogs

MVP / VIP
Local time
Today, 09:22
Joined
Jan 14, 2017
Messages
18,209
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:

theDBguy

I’m here to help
Staff member
Local time
Today, 01:22
Joined
Oct 29, 2018
Messages
21,449
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

Top Bottom