How to execute a module in MS access when the access file is open

D

Dominique Ighedosa

Hello,
I need some help. How would you automatically execute a
module in MS access when a user opens the access file?
My email address is (e-mail address removed).

Regards,

Dom
 
S

Steve Renier

Dom:

Create a macro and use the OpenModule command to reference
both your module and the functions that you wish to run.
You will have to reference each function separately with
successive commands. Name the macro AutoExec.

When you start up the Access application, the AutoExec
macro will automatically start and execute the OpenModule
commands.

Steve
 
G

Guest

Steve, thanks for your speedy response. I did exactly what
you said but the module doesn't execute the code. When I
open the access file, it opens my Module but it doesn't
execute the code. Can you please help.
In addition, how can I close the Access file once the
module is done exectuing?
 
M

Marshall Barton

Dominique said:
I need some help. How would you automatically execute a
module in MS access when a user opens the access file?

You don't execute a module, you execute a procedure in a
module.

One way to run code when the database opens is to create a
macro named AutoExec and add one line to the macro using the
RunCode action with the name of the function that you want
to execute. Note that the procedure must be a Public
Function in a standard module.
 
D

Dominique

Hey Marshall, thank you very much for your response. It
worked fine. Have a great day!
 
M

Marshall Barton

Dominique said:
Hey Marshall, thank you very much for your response. It
worked fine. Have a great day!

Glad to be able to help. You have a great day too.
--
Marsh
MVP [MS Access]

 

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