Part II: Programming Microsoft Access
488
The Object Browser is easy to use. Select a library (ADODB, for example) from the drop-down list
in the upper-left corner; then scroll through the object list on the left side of the browser to find an
object of interest. Selecting an object fills the right-side list with the object’s properties, methods,
and events (if applicable). Clicking on a property, method, or event reveals the item’s syntax in the
area below the lists.
Although the Object Browser doesn’t show specific code examples, very often seeing the syntax
associated with property, method, or event may be enough to get you started writing VBA code, or
to clarify the object’s details.
Understanding ADO Objects
I’ll begin my explanation of the ActiveX Data Objects by examining the ADO object model, and
describing the purpose of each object. Then I’ll look at a number of code examples that use the
ADO objects to perform common database tasks.
The ADO object model is shown in Figure 13.8. As you can see, the ADO object model is quite
simple and includes only a few types of objects. Notice that the ADO object model is not hierarchi-
cal. Each object stands alone and is not subordinate to another object in the model.
FIGURE 13.8
The ADO object model
Connection
Recordset
Command
Properties
Properties
Fields Properties
Parameters
Using ADO objects requires a reference to the ADO library. Figure 13.9 shows the References dia-
log box (opened by choosing Tools ➪ References in the VBA editor window) with the ADO library
(Microsoft ActiveX Data Objects) selected. The exact version of the ADO library installed on your
machine may vary, and, in fact, there may be more than one ADO library in the References dialog
box. Select the highest-numbered library to make sure you have the latest version available to
Access.