Running code from a module


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?

Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

mrt1Connect With a Mentor Commented:
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.
All Courses

From novice to tech pro — start learning today.