Microsoft Office Tutorials and References
In Depth Information
Testing and Running Your Code
Figure 2-14:
Sample
compile
error.
The compile error means that the line you typed can’t be translated to
instructions that Access can perform. Access can compile and execute only
syntactically correct and complete statements. The message Expected:
list separator or ) tells you that Access expected to find either a
comma (to separate the first argument from the second) or a closing
parenthesis.
The box displaying the error message contains two buttons:
OK: Closes the error message box so that you can type the correction
Help: Provides some general information about the type of error
discovered and provides some suggestions for fixing the problem
Regardless of which button you click, you need to correct the statement
before it can work correctly. After you type the correct statement and press
Enter, the error message no longer appears, and the line no longer displays
in red.
Testing and Running Your Code
A completed procedure is generally called from some object, such as a
button on a form. As you write code, however, you may want to make sure
that it will work before you start attaching a procedure to objects in your
database. You can use the Immediate window to run the procedure right on
the spot. The syntax you use depends on whether you’re testing a sub
procedure or function, as well as on whether the procedure accepts arguments.
Book VIII
Chapter 2
Testing sub procedures
To test a sub procedure that accepts no parameters, you simply type the
name of the sub procedure in the Immediate window and then press Enter.
The following procedure accepts no parameters and displays a message box
when called:
Sub ShowThanks()
MsgBox (“Thank you”)
End Sub
Search JabSto ::




Custom Search