Parameter Info

Some VBA functions and methods can take one or more arguments (or parameters). If a Visual Basic function or method requires an argument, you can see the names of required and optional arguments in a tip box that appears just below the cursor as soon as you type the open parenthesis or enter a space. The Parameter Info feature (see Figure 2-10) makes it easy for you to supply correct arguments to a VBA function or method. In addition, it reminds you of two other things that are very important for the function or method to work correctly: the order of the arguments and the required data type of each argument. To see how this works, enter the following instruction in the Code window:

DoCmd.OpenForm

As soon as you enter a space after the OpenForm method, a tip window appears just below the cursor. The current argument is displayed in bold. Then as soon as you supply the first argument and enter the comma, Visual Basic displays the next argument in bold. Optional arguments are surrounded by square brackets [ ]. To close the Parameter Info window, press Esc. To open the tip window using the keyboard, enter the instruction or function, followed by the left parenthesis, and press Ctrl+Shift+I. You can also click the Parameter Info button on the Edit toolbar or choose Edit | Parameter Info from the menu bar.

- openAt-orm

Option Compare Database

Sub OpenAFormO

Op enF u rrn (FomiWame, [Vimt As AcF o rrnVlew = a c Normal], [FltterName], [Wterecondtliori], [Dat&Wode As End 3 u AcFo rmOpen DataM ode = acFo rmP ro p ertyS ettin gs]. [WindovMode ¿5 Ac Win d owMod e - acWindowN orm al], \0&sr>Arg$>

-

=±J_1

Figure 2-10: A tip window displays a list of arguments utilized by a VBA function or method.

Figure 2-10: A tip window displays a list of arguments utilized by a VBA function or method.

To display the Parameter Info window when entering a VBA function, type the following in the Immediate window:

Mkdir(

You should see the MkDir(Path As String) tip window just below the cursor. Now, type "C:\NewFolder" followed by the ending parenthesis. When you press Enter, Visual Basic will create a folder named NewFolder in the root directory of your computer. Activate the Explorer and check it out!

Introduction to Access 2003 VBA Programming

0 0

Post a comment