Part IV: Professional Database Development
970
Note
In the lexicon of object-oriented programming, a class is a code element that defines an object. A good analogy
for a class module is the engineering specification that defines a car or airplane. You create an object using the
class as its specification. You add code to the class module to define the object’s properties and methods.
Modifying the code in a class module modifies how the object defined by the class module behaves.
On the CD-ROM
This chapter uses the database Chapter28.accdb. If you haven’t already copied it onto your machine from
the CD, you’ll need to do so now.
Introducing Object-Oriented Programming
The world is filled with objects. The car you drive, the computer you use, and the radio you listen
to are all examples of objects. Some objects, such as a desk lamp, are relatively simple, while other
objects, such as a stealth bomber, are considerably more complex.
In addition to physical objects, the world is filled with objects you can’t feel or touch. Electricity,
sound, and light are all examples of objects people can produce, measure, and use, but you can’t
sense them as physical entities. An object’s visible characteristics have little to do with its value to
people. The electricity coursing through your computer’s circuitry can be as valuable as the car you
drive, under the right conditions.
You’ll find any number of visible and invisible objects in most Access databases. And, just as with
the objects that make up our environment, the invisible objects in an Access database can be as
valuable as the forms, menus, and ribbons the user sees.
Getting to know objects
An Access object is a programmable entity of one sort or another. The Err object is an example of
an invisible, but valuable, object built into Access. You use the Err object’s properties (Number,
Description, and so on) to determine which error has occurred. The Clear method resets the
Err object, preparing it for the next error to occur. Even though the Err object never appears on
an Access form or report, it has an important role in every professional Access application.
Understanding what objects are
Although there’s an endless variety of objects, all objects have features in common:
l An object is a programmable entity. Most objects contain a number of properties you
can read or set at runtime.
l Most objects include methods you can execute to perform tasks. An object’s proper-
ties and methods define the object’s interface to the rest of the program.