On Startup code

D

Dave Green

I want to have some VBA code run when the database is
opened that will import a table but first deleting the
existing one. I know the code for the import and delete
but I am having trouble getting my code to run at startup.
I don't know where to put my code or how to invoke it. Can
anybody help?

Thanks,

Dave
 
D

Dirk Goldgar

Dave Green said:
I want to have some VBA code run when the database is
opened that will import a table but first deleting the
existing one. I know the code for the import and delete
but I am having trouble getting my code to run at startup.
I don't know where to put my code or how to invoke it. Can
anybody help?

There are two main ways:

1. Use the RunCode action in an Autoexec macro to execute it. The code
must be written as a Public Function, not a Sub, in a standard module.

2. Set a Startup form for your database (in the Tools -> Startup...)
dialog, and execute your code in that form's Open or Load event
procedure.
 
U

Upendra Agnihotram

Dear Dave,

You can achieve this in two ways.

Write your functionality in a Public function in a module

Call this function in StartUp form (you can create a startup form using
Tools-->Startup-->select Your form)
or
Write a macro and Name int Autoexec in the Action column Select Runcode
from the pull down list, Give your function name in Function Name input box.

Regards,
Upendra
 
Top