Chapter 32. Object-Oriented Programming with VBA


  • Learning object-oriented programming techniques

  • Understanding the benefits of object-oriented programming techniques

  • Creating class modules

  • Adding properties to class modules

  • Creating and using methods

  • Declaring, raising, and sinking events

  • Using class modules in unbound forms

A major incentive in all modern application development is to produce robust, reusable code. Microsoft Access provides a number of ways to make code more reusable, beginning with simple import or export of code modules on through building runtime code libraries.

This chapter covers one approach to creating code modules you can reuse from any Access database. The code modules we describe in this chapter 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 objects. Microsoft defines just about everything in an Access application as some kind of object. All the forms, the controls on the forms, the reports, and other visible parts of your programs are objects.

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

Get Access™ 2007 Bible now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.