Similar to the standard modules that you create, you can also create class modules with the Visual Basic Editor. You usually begin a class module in Design view for a form or report. In most cases, class modules are associated with events such as clicking a form button or opening the form. Unlike standard modules, class modules do not appear in the Modules Object list in the Database window. Instead, you can access them from within the Project Explorer.
Create a Class Module for a Form or Report
- Display a form or report in Design view.
- Click the control or object within the form or report in which you want to create a class module, and then click the Properties button on the toolbar.
- Click the Event tab.
- Click the event box that you want to associate with a VBA procedure.
- Click the Build button.
- Click Code Builder.
- Click OK.The Visual Basic Editor opens a Modules window and automatically creates an Event procedure for the control and event you selected.
- Enter the VBA commands you want.