Datasheet

Book VIII
Chapter 1
What the Heck
Is VBA?
Using the Visual Basic Editor
581
When the Immediate window is open, you can anchor it to the bottom of the
Visual Basic Editor just by dragging its title bar to the bottom of the window.
Optionally, you can make the Immediate window free-floating by dragging its
title bar up and away from the bottom of the Visual Basic Editor program
window. You can also dock and undock the Immediate window by right-
clicking within the Immediate window and choosing the Dockable option
from the shortcut menu that appears.
The Immediate window allows you to test expressions, run VBA procedures
you create, and more. To test an expression, you can use the
debug.print
command, or the abbreviated ? version, followed by a blank space and the
expression. Which command you use doesn’t matter, although obviously,
typing the question mark is easier. You may think of the
? character in the
Immediate window as standing for
“What is . . . ?” Typing ? 1+1 into the
Immediate window and pressing Enter is like asking, “What is one plus one?”
The Immediate window returns the answer to your question,
2, as shown in
Figure 1-11.
If you see a message about macro content being blocked, switch over to
the Access program window and click the Enable Content button on the
Security bar.
If you want to re-execute a line that you already typed into the Immediate
window, you don’t need to type that same line in again. Instead, just move
the cursor to the end of the line that you want to re-execute and press Enter.
To erase text from the Immediate window, drag the mouse pointer through
whatever text you want to erase. Then press the Delete (Del) key or right-
click the selected text and choose the Cut option from the shortcut menu.
You see many examples of using the Immediate window in the forthcoming
chapters of this book. For the purposes of this chapter, knowing the
Immediate window exists and basically how it works is enough.
Figure 1-11:
The free-
floating
Immediate
window
solves 1 + 1
calculation.
38_036494 bk08ch01.qxp 11/17/06 8:34 AM Page 581