O'Reilly logo

Beginning Access™ 2007 VBA by Denise Gosnell

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

4.1. Using Class Modules to Create Your Own Objects

As you have already learned, an object refers to all the things that make up your database, including forms, reports, and controls. By encapsulating code into objects, you make programs easier to maintain and code easier to reuse. You also have learned that objects can have properties, methods, and events. Properties are characteristics of the object, and methods are actions you take upon the object. Events are triggered when a user or application performs an action. These objects, which you worked with in Chapter 3, were created using class modules, although you did not see the proprietary source code for the Access objects.

You may remember from Chapter 2 that a class module is only one of the two types of modules; the other type is a standard module. Standard modules are modules that contain procedures that are not associated with any particular object. The procedures you wrote in the modBusinessLogic module in Chapter 2 were placed in a standard module. Class modules are modules that are associated with a particular object. Class modules can be used either for form or report modules or for custom objects. For example, form and report class modules can contain code that corresponds to a particular form or report, such as the event procedures for forms and controls that you wrote in the corresponding form class module in an earlier chapter. Since Access 97, class modules can also be created independently of a form or report ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required