Chapter 8. Creating Classes in VBA

WHAT'S IN THIS CHAPTER?

  • Introduction to principles of using class modules in Access such as naming and organization

  • The pieces that make up a class module including properties, methods, enumerations, and events

  • Subclassing Access forms to extend them using your own code

  • Writing collection classes to help you group similar objects together

  • Core principles of object-oriented programming and how they translate to writing class modules in VBA

In object-oriented programming (OOP), an object is a unique instance of a data structure, called a class, that has both properties (which define its characteristics) and procedures called methods (which define its behavior).

Classes have been likened to rubber stamps, cookie-cutters, and several other everyday items in an attempt to make the concept more understandable. Because you are reading a book on software development, it seems fairly safe to assume that you understand the concept of a template, such as a Microsoft Word template. Templates are a good way to think about the distinction between a class module and a class instance. The class module is equivalent to a Word template and an instance of the class would be equivalent to a Word document that is based on that template. In other words, the class module defines the definition of an object, while the object itself is an instance of a class. The class module is used to define properties, methods, and events, which collectively make up the object's interface ...

Get Microsoft® Access® 2010 Programmer's Reference 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.