I am seeking comments on how to schedule auto updates of a database (.accdb) since I am not very comfortable with the process I have set up.
Currently, it works as follow:
- Task Scheduler calls a .bat
- .bat calls a .vbs
- .vbs opens the database and calls a macro
- The macro calls a function (VBA Level)
- The function calls the update Subroutine
I consider there are too many steps and the fact that it requires 2 external files (.Bat and .vbs) related to the database and stored on the system increase the risk that the procedure would break.
Apparently (but please tell me that I am wrong and how I can change it) .vbs cannot call a subroutine but only a macro. Identically, an access macro cannot call a subroutine but only a function if the user is expecting to enter the VB environment of the database. This is the reason why I called a function (VBA Level) that then calls the subroutine.
Hope some of you know how to shorten the steps and eventually get ride of the .bat and .vbs
.bat
or your.vbs
script anything more than a single line of code? If not, then you probably could just update your Scheduled Task to runMSACCESS.EXE
with the required parameters. (2) Yes, a Macro in Access can only invoke a Function, but you could probably convert your Sub to a Function that doesn't return anything (or returns some arbitrary value likeTrue
). – Hosbein-x
command-line switch and the name of the macro you want to run. Details here. – Hosbein