Chapter 10: VBA Programming Fundamentals
391
FIGURE 10.7
Accessing a control’s event procedure from the Property Sheet
Notice the [Event Procedure] in the control’s On Click property. It tells you that there is
code attached to the control’s Click event. Clicking on the builder button (with the ellipsis, or.. .)
in the On Click property opens a dialog box where you can choose to build a macro or VBA
code, or create an expression for the event. Choosing the Code Builder option opens the VBA code
editor, displaying the event procedure.
Tip
Many Access developers prefer to routinely use VBA code for their procedures. You can instruct Access to
always use VBA code by selecting the Always Use Event Procedures check box in the Form/Report Design view
section under Object Designers in the Access Options screen (found in the Backstage).
Caution
Event procedures that directly work with a form or report belong in the module of the form or report. A form’s
module should contain only the declarations and event procedures needed for that form and its controls (but-
tons, check boxes, labels, text boxes, combo boxes, and so on). Placing procedures shared with other forms in
a form’s module really doesn’t make sense and should be avoided.
Creating a new module
Using the Modules section of the Navigation Pane, you create and edit VBA code contained in stan-
dard modules. You could, for example, create a Beep procedure that makes the computer beep as
a warning or notification that something has happened in your program.