Run a VBA Module on Startup

  • Thread starter Thread starter Mike Thomas
  • Start date Start date
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
 
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
 
(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).
 
Back
Top