Microsoft Access 2010 Bible

(Rick Simeone) #1

Part II: Programming Microsoft Access


414


As an example, assume you’ve set up the following sort of statements in all the modules in your
application:

#If CC_DEBUG2 Then
MsgBox “Now in ProcessRecords()”
#End If

Instead of adding the constant directive (#Const CC_DEBUG2 = True) to every module in the
application, you might enter the following text into the Conditional Compilation Arguments text box:

CC_DEBUG2 = -1

This directive sets the value of CC_DEBUG2 to –1 (True) for all modules (global and form and
report class modules) in the application. You need to change only this one entry to CC_DEBUG2=0
to disable the debugging statements in all modules in the application.

Note
You don’t use the words True or False when setting compiler constants in the Project Properties dialog box,
even though you do use these values within a VBA code module. You must use –1 for True and 0 for False
in the Project Properties dialog box.


Separate multiple arguments with colons — for example: CC_DEBUG1=0 : CC_DEBUG2=-1.

Command-line arguments
The Options dialog box you open from the File menu (click on the large round Microsoft Office
Button in the upper-left corner of the main Access window, and choose File ➪ Access Options)
provides a number of interesting options. Select the Advanced tab and scroll down to the
Advanced section near the bottom of the dialog box. Notice the Command-Line Arguments text
box at the very bottom of the Advanced section.

Many applications use command-line arguments to influence how the application behaves at run-
time. You could, for example, add a command-line argument to an Access database application
that indicates whether the user was an experienced or novice user. The application might display
help and other assistance that is appropriate for the user’s experience level. (Use the Command
function to return the arguments portion of the command-line used to start Access or the Access
runtime environment.)

Passing a Windows application command-line arguments during development has always been dif-
ficult. Windows requires command-line arguments to be passed as text in the Target text box of a
program icon’s Property Sheet. Figure 10.23 shows such a Property Sheet. The text /User
Novice in the Target text box is the command-line argument passed to the Access application as
it starts up.
Free download pdf