Microsoft Access 2010 Bible

(Rick Simeone) #1

Chapter 10: VBA Programming Fundamentals


399


Choosing the Code Builder item opens the VBA code editor, as shown in Figure 10.15. Clicking
the View Microsoft Access button in the code window’s toolbar toggles between the form designer
and the VBA code window.

FIGURE 10.15

A form module open in Design view


Editing an existing procedure
There a number of ways to access existing code behind a form or report. These are by far the most
common:

l (^) Click the View Code button in the Tools group in the Access ribbon (with the form or
report open in Design view, of course).
l (^) Select an event procedure from a control’s event property (refer to Figure 10.7).
Opening a standard module is even easier. Simply select Modules in the Navigation Pane; then
right-click on a module and select Design View from the shortcut menu (see Figure 10.16).
Checking your results in the Immediate window
When you write code for a procedure, you might want to try the procedure while you’re in the
module, or you might need to check the results of an expression. The Immediate window (shown
in Figure 10.17) enables you to try your procedures without leaving the module. You can run the
module and check variables. You could, for example, type? and the name of the variable.
Press Ctrl+G to view the Immediate window, or choose View ➪ Immediate Window in the VBA
code editor.

Free download pdf