Datasheet
Using the Visual Basic Editor
582
Do bear in mind that the Immediate window is just for testing and debug-
ging. The Code window is where you type (or paste in) VBA code.
Using the Object Browser
VBA code can manipulate Access objects programmatically. Remember,
everything in Access is an object — tables, forms, reports, and even a single
control on a form or report are objects. Every Access object you see on-
screen in Access is managed either interactively or programmatically. When
you work with objects in the Access program window, using your mouse and
keyboard, you use Access interactively. You do something with your mouse
and keyboard and the object responds accordingly.
When you write code, you write instructions that tell Access to manipulate
an object
programmatically, without user intervention. You write instructions
to automate some task that you may otherwise do interactively with mouse
and keyboard. In order to manipulate an object programmatically, you write
code that refers to the object by name.
All the objects that make up Access and the current database are organized
into an
object model, which comprises one or more object libraries. An object
library
is an actual file on your hard drive that provides the names of objects
that VBA refers to and manipulates.
Each object consists of
classes, where each class is a single programmable
object. Each class has
members, and some members are properties.
Properties are characteristics of the class, such as its name, or the number
of items it contains. Other members are
methods, which expose things you
can do to the class programmatically.
The object model is huge and contains many libraries and classes. There’s
no way to memorize everything in the object model. It’s just too darn big.
The Visual Basic Editor provides an Object Browser that acts as a central
resource for finding things as well as getting help with things in the model.
It’s especially useful for deciphering other peoples’ code, like the examples
you’ll see in this book.
To view the objects that VBA can access, follow these steps to open the
Object Browser:
1. Make sure you’re in the Visual Basic Editor.
2. Click the Object Browser button in the toolbar, choose View➪Object
Browser from the menu, or press the F2 key.
The Object Browser opens. Figure 1-12 shows the Object Browser and points
out some of the major features of its window. The following list describes
each component:
38_036494 bk08ch01.qxp 11/17/06 8:34 AM Page 582