< Day Day Up > |
After launching the VBE, you'll probably want to view existing code or enter new code. All VBA code is contained in one of three types of modules:
To insert a standard or class module, choose Insert, Module or Insert, Class Module, respectively. Access responds by inserting the appropriate type module. Figure 2.4 shows a standard module in the VBE. Notice how inserting a new module updates the contents of both the Project Explorer and the Properties window. Enter procedures that are independent of any objects or events in a standard module. You can use objects and events in the code, but the module itself isn't defined by an object nor does it contain any predefined events. Figure 2.4. Modules contain the VBA code that automates your database.Object modules come with the forms or reports you create. They're really a type of class module, but you don't have to reinvent the wheel every time you want to add code to a form or report. These modules come with your forms and reports. The code in an object module is usually triggered by and responds to the object's events. However, an object module can contain a procedure that's not related to an event. TIP There are a number of keyboard shortcuts for moving around the VBE. Many of these are listed in Table 2.1, but there are many others. For instance, pressing Shift+F10 displays the active window's shortcut menu. (You can also display this menu by right-clicking the window.) To learn more shortcuts, search in the special VBA Help files for "Keyboard Shortcuts." |
< Day Day Up > |