Home / MS-Access / Getting Started

Object-Oriented Programming with VBA

This tutorial covers one approach to creating code modules that you can reuse from any Access database. The code modules we describe in this tutorial define new types of objects for your Access applications. These objects include properties and methods, and you can copy the objects into other Access applications or add them to Access code libraries.

The objects you create enforce modular, object-based programming. You've likely noticed how Access is based on the concept of objects. Microsoft defines just about everything in an Access application - forms, controls on forms, reports, and other visible parts of your programs - as some kind of object.

In addition, any number of hidden objects (such as table relationships) are lurking in your program. These objects are one of the ways in which Access is modular in nature. Each built-in Access object (such as a table, query, or form) performs some task in the application.

Here you'll learn what objects are and how to use them in your applications. You'll also find out how to build your own objects using Access VBA code.

Although this tutorial discusses objects such as forms and controls as examples, the emphasis is on the technology of creating and using custom objects in your Access applications. You create custom objects in your applications by adding code to a special class module.

Note: 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.