Run a VBA Module on Startup

M

Mike Thomas

Our app needs to run a VBA module which relinks tables from another mdb.

I was running it via the AutoExec macro, but have run into a a strange
problem and would like to eliminate the macro alltogether.

Is there a way I can run the VBA module when the mdb is opened without doing
it through a macro? Perhaps some sort of application event?

The mdb opens with the Switchboard form. I could run the module from the
Open event of that form, but I'd like to run it before any forms open.

Thanks
Mike Thomas
 
P

Peter Doering

Mike,
Our app needs to run a VBA module which relinks tables from another mdb.
I was running it via the AutoExec macro, but have run into a a strange
problem and would like to eliminate the macro alltogether.
Is there a way I can run the VBA module when the mdb is opened without doing
it through a macro? Perhaps some sort of application event?
The mdb opens with the Switchboard form. I could run the module from the
Open event of that form, but I'd like to run it before any forms open.

That's what most people do to avoid autoexec:

- Create a new form.
- Make it the startup form.
- Execute the procedure in this form's open event.
- When finished, open the switchboard.
- Close the form again.

HTH - Peter
 
V

Van T. Dinh

(in addition to Peter's reply).

Create a new unbound frmDummy as set this as the Startup Form. Use the
Form_Open Event of the frmDummy to:

1. Run the re-linking code.
2. Open the Switchboard Form
3. Close the frmDummy (or set the Cancel Property to True).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top