Running code from a module

Hi,

This my sound stupid, but here it goes:

I've got a module in my Access 97 database with one procedure:

Sub Test
   MsgBox "test"
End Sub

When I save the module, it's listed in the modules tab but the button "run" on the right is not enabled; I can only run the code when:

- the module is openen
- the cursor is in the sub and
- clicking "play"

How can I enable the "run" button from the module tab to automatically run the test procedure?

Thanks.
LVL 2
SLEAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mrt1Commented:
Modules can contain many functions and subroutines, so you can't "run" a module. The "run" button is always disabled.

You can run a function or sub by:

1. Opening the module and manually running the code (from the toolbar or via the immediate window).

2. Calling the function from an event (in a form or report)

3. Calling the function from a query. (used when the function performs some calculation on a particular field).

4. Calling the function from a macro, using the RunCode action.

These are the only four ways I can think of at the moment. Think of the module as a library of code, rather than an object in its own right.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.