Chapter 2. The Basics of Writing and Testing VBA Code
Chapter 1 introduced the Access VBA programming environment and some general software development concepts. At this point, you are ready to learn the basics of writing and testing code using VBA. This chapter will cover:
Creating code modules
Creating and calling procedures
Using variables to store values
Controlling the flow of programs
Debugging and handling errors
This chapter will serve as a building block for the more advanced VBA concepts covered in later chapters. The techniques covered in this chapter and in most of the remaining chapters are used during the development and testing phases of the Systems Development Life Cycle, as defined in Chapter 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.
Object navigation box—Use to select the object to work with.
Declarations/Procedure navigation box—Use to navigate to the general declarations section or to a particular procedure.
Figure 2.1. Figure 2.1
Declarations—Contains the declarations ...
Get Beginning Access 2003 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.