2.1. VBA in Access

If you're reading this book, you've made the decision to use VBA in Access to develop your application. VBA in Access can be implemented in several places, such as writing VBA code in modules and behind controls on forms and reports. You take a quick look at both types of code in this section. Later chapters will provide in-depth coverage of VBA in forms and reports as well as the many different uses of VBA in modules.

2.1.1. Writing Code in Modules

A module is a container for code. You can store various subs, functions, and declarations in a module. To view all modules currently available in your Access database, click the Modules group of the Access navigation pane. To view a module, double-click it to open the Visual Basic Editor (see Figure 2-1).

Chapter 4 explores the various components of the VBA Editor in detail, but you'll notice that by default, the VBA Editor contains a Project Explorer, a Properties dialog box, and the main code editor. If you have various modules available in your project, they are listed in the Project Explorer in the upper-left pane. The Properties pane (lower-right) displays the properties for the currently selected object (either the module itself, or a control or form within the module).

Figure 2.1. Figure 2-1

2.1.2. Writing Code Behind Forms and Reports

Before you dive head first into VBA, you might want to get your feet ...

Get Access™ 2007 VBA Programmer's Reference 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.