How to run VBA program automatically from database

ChristineC

New member
Local time
Today, 10:42
Joined
Apr 1, 2001
Messages
7
Hi all,
I'm doing a project for college which provides a service to registered users of my website. I have a number of program that need to be run in the background to provide this service. These programs will be run sequentially using an MSDOS Batch file. The problem is that one of these programs is written in VBA using the modules section of MS Access. What path do I use to call this program for running. I've used G:\database.mdb But this just calls the database, I need it to go to modules and run the VBA program stored there.
If anyone can help me or give me some advice I would greatly appreciate it.
thanks a million
Christine
 
You need to create a startup form (any form can be set to open automatically on startup in the tools/startup dialog.

Then in the OnLoad event of that form, you can have code that calls the code you've written in the module(s), alternatively, you could just put the code straight into the Onload event, rather than calling it.

You might also want DoCmd.Quit at the end of it all, so that the database closes itself down when finished.

HTH

Mike
 
one other thing though; I don't think the batch file will wait while Access finishes (It may continue running behind Access), so if you have any processes in the batch file AFTER the Access operation, that depend on data that Access is updating, it might not work properly.

Are the other operations that you describe proprietary programs or are they functions that could be handled in VBA?

Mike
 
What/where is the onload event of the form?
The actual program in the modules section is a parsing program which parses information form a webpage and stores it in a table in my database.
This information is then automatically matched with users information by a query and then an email is sent to users with matches.
the email cannot be sent witout the matches.
I have not written the email program yet but I'm planning to do it in VBscript.
 
As an alternative to having a startup form, you could set up a macro that would run your code. Then have your automation process start Access and run the macro:
G:\somefolder\MyMDB.mdb /x mMyMacro

You need to put in the right path to your MDB. The /x says to skip any startup. You should add a step in the macro or in the code to shut down Access when you are through.
 
Here's how to put code into the OnLoad event of a form:

-Open the form in design view
-Click in the blank space beside the grey form background
-If the Properties box isn't visible, Select View/Properties
-Select the 'Event' tab
-click just to the right of the white (combo) box for the On Load Item (you'll find, after you click there, that you've clicked a little button with three dots on it.
-Select Code Builder
-Put your code in there; it will run every time the form is opened

HTH

Mike
 
If you create a macro to run the code, and name it "AutoExec", it will automatically run when the db opens.
 
or write any Autoexec-macro containing
"RunCode..."
calling any public function (like "configuration()" )in your database

Mic
 
I'm new to Access development. Is it just me, or does the RunCode not work for calling public subroutines?
 
Hi, I have a program in my database that I would like to have run every morning at 7:15. I'm using Access 97 and running on Win 98. I tried using the scheduler program and have it set to run a test macro:

"C:\My Documents\newdatabase\one.mdb \x Test"

at whatever time and it won't open. Am I setting something wrong in the scheduler? I thought I was entering everything in correctly but not sure why it isn't working. Any ideas on this or possibly other methods that I can use. Thanks for any help.
 
Mendel... my observation (this stuff is way over my head) is that you have the \x with the wrong /....

(Hope im not way off)

smile.gif

ben
 

Users who are viewing this thread

Back
Top Bottom