Chapter 14: Debugging Your Access Applications
537
Using Debug.Print
The second commonly used debugging statement is using Debug.Print to output messages to
the Immediate window. (Print is actually a method of the Debug object.) Figure 14.12 shows
how the sSQL variable appears in the Immediate window.
FIGURE 14.12
Use Debug.Print to output messages to the Immediate window.
Conditional Compilation Arguments and other settings set in the Project Properties dialog box are relevant
only to the current application. Unlike the options you set in the Options dialog box (accessible from the
Tools menu), the Project Properties settings are not shared among multiple Access applications.
Tip
In the preceding figure, notice that the values assigned to the Conditional Compilation Arguments are all
numeric. Assigning zero to a Conditional Compilation Argument sets the argument’s logical value to
False; any nonzero value is interpreted as True. You can’t use the words True and False in the
Conditional Compilation Arguments text box. Setting the value to 0 (false) means that you can leave all
the conditional compilation directives in your code. Setting the value to false effectively disables them,
allowing your code to execute as if they don’t exist.
If you’re confused about the conflicting terminologies applied to the VBA conditional compilation fea-
ture, you’re not alone. In a VBA code module, you assign conditional compilation constants using the
#Const keyword, yet in the Project Properties dialog box, you set Conditional Compilation Arguments.
Also, you assign the True and False keywords to conditional compilation constants in a VBA module,
but use 1 and 0 to assign True and False, respectively, to Conditional Compilation Arguments. This
is one place where the terminology and syntax used for the same purpose are quite different in different
parts of an Access VBA project.
In case you’re wondering, the name you apply to a compiler constant is anything you want it to be. The
example in this section uses DEBUG1 merely as a convenience, but it could have been
MyComplierConstant, Betty, DooDah, or any other valid constant name.