How to run VBA program automatically from database (1 Viewer)

ChristineC

New member
Local time
Today, 14:46
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
 

Atomic Shrimp

Humanoid lifeform
Local time
Today, 14:46
Joined
Jun 16, 2000
Messages
1,954
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
 

Atomic Shrimp

Humanoid lifeform
Local time
Today, 14:46
Joined
Jun 16, 2000
Messages
1,954
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
 

ChristineC

New member
Local time
Today, 14:46
Joined
Apr 1, 2001
Messages
7
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.
 

Chris RR

Registered User.
Local time
Today, 08:46
Joined
Mar 2, 2000
Messages
354
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.
 

Atomic Shrimp

Humanoid lifeform
Local time
Today, 14:46
Joined
Jun 16, 2000
Messages
1,954
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
 

charityg

Registered User.
Local time
Today, 14:46
Joined
Apr 17, 2001
Messages
634
If you create a macro to run the code, and name it "AutoExec", it will automatically run when the db opens.
 

MHM

Registered User.
Local time
Today, 14:46
Joined
Mar 15, 2000
Messages
101
or write any Autoexec-macro containing
"RunCode..."
calling any public function (like "configuration()" )in your database

Mic
 
M

muleherd

Guest
I'm new to Access development. Is it just me, or does the RunCode not work for calling public subroutines?
 

Mendel

Registered User.
Local time
Today, 14:46
Joined
Jan 18, 2001
Messages
34
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.
 

bmwilson

Registered User.
Local time
Today, 14:46
Joined
Dec 6, 2001
Messages
18
Mendel... my observation (this stuff is way over my head) is that you have the \x with the wrong /....

(Hope im not way off)


ben
 

Users who are viewing this thread

Top Bottom