Chapter 32. Object-Oriented Programming with VBA

IN THIS CHAPTER

  • 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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.