Creating a Standard Module

Before you start writing code, you need a place to put it. Putting your code in standard modules is always a good bet because code in standard modules is accessible to all objects within a database. Creating a new standard module is easy. Just follow these steps:

1. In your Access database, click Modules at the left side of the database window.

2. Click the New button, as shown in Figure 3-1.

Figure 3-1:

Begin by creating a new standard module.

Figure 3-1:

Begin by creating a new standard module.

1. Click Modules

2. Click New

1. Click Modules

2. Click New

The new module will open in the VBA Editor. Most likely, it will be empty except for the words Option Compare Database at the top. That line, a module-level declaration, just tells VBA that when comparing values, it should use the same rules as the rest of the database. You don't need to change or remove that declaration line.

As I discuss in Chapter 1, a module contains VBA code that's organized into one or more procedures. A procedure is simply the set of steps needed to perform some task. A new standard module contains no procedures because it's empty. Thus, the first step to writing code is to create a procedure.

0 0

Post a comment