13.3. Creating a Class Module
Everyone learns best by doing, so to learn the basics of creating a class module, you'll create one. The class module will model a classroom at a school. You'll see this example throughout the chapter, showing the different parts of a class module and how to model its relationships with other classes.
13.3.1. Adding a Class Module to the Project
The easiest way to add a new class module to your project is to press Alt+F11 to open the Visual Basic Editor. Then, in the Visual Basic designer window, select Insert Class Module. You can also right-click anywhere in the Project Explorer and select Insert Class Module from the context menu. In addition, you can also create a class module from within Access by selecting Class Module under the Macro split button in the Other group in the Ribbon's Create tab.
VBA opens a new class module and adds a reference to it in the Project Explorer. Copy the clsClassroom code into the module as shown in Figure 13-3. That's it! You've created your first class module!
Figure 13.3. Figure 13-3
13.3.2. A Brief Word on Naming the Class
All things have names, and class modules are no different. The name you give a class module, ...
Get Access™ 2007 VBA 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.