2.1. Creating Modules

Modules are best described as containers for holding VBA code. Modules can contain declarations and procedures. VBA code that is placed in one or more modules can be called from an Access application to perform a specified task. I discuss this in greater detail throughout.

Figure 2-1 shows a sample module displayed in the Visual Basic Editor.

Note that the previous figure has four areas labeled. Each one will now be mentioned briefly.

  1. Object navigation box – Use to select the object to work with

  2. Declarations/Procedure navigation box – Use to navigate to the general declarations section or to a particular procedure

  3. Declarations – Contains the declarations for the module

  4. Procedures – Contains the sub procedures and functions for the module

Figure 2.1. Figure 2-1

When you select the Declarations/Procedure navigation box, a list appears that displays the existing procedures of the module, as shown in Figure 2-2.

Now that you have a basic idea of what a module is (container for code), let's turn to the different types of modules.

Figure 2.2. Figure 2-2

Get Beginning Access™ 2007 VBA now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.