Intrinsic Constants


Variables and constants both represent particular values. However, a variable’s value will change as circumstances dictate, but a constant will always retain the same value. As an example, the value of pi would certainly not change.

You declare a variable with the keyword Dim, and a constant with the keyword Const. There are also constants called intrinsic constants that are built into Access, VBA, or the ADO library. The origin of these intrinsic constants can be identified by their prefix. For example:

  • The prefix vb refers to a Visual Basic constant.

  • The prefix ac refers to an Access constant.

  • The prefix ad refers to an ADO constant.

VBA has hundreds of such constants built in. As an example, open the Object Browser and do a search for constants. Then, click on one of the VBA libraries. You will get something resembling Figure 8-1. These constants should work properly anywhere in your code.

click to expand
Figure 8-1: VBA constants

Again, if you use the Object Browser and click on one of the Access libraries, you will get something that looks like Figure 8-2. Before version 2000 of Access, these names used the convention of the letter A followed by an underscore, for example, A_Next or A_ Record.

click to expand
Figure 8-2: Access constants

We will be exploring ADO constants as we progress further through the book.




Access VBA Programming
Microsoft Access VBA Programming for the Absolute Beginner
ISBN: 1598633937
EAN: 2147483647
Year: 2006
Pages: 214
Authors: Michael Vine

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net