Appendix A. Naming Conventions

This appendix gives you suggestions for naming variables and other database objects. The suggested standards are based on the Reddick VBA Naming Conventions (RVBA), which are commonly accepted in the industry.

When you’re creating variable names, it’s important to make the type and intended use of each variable clear and self-documenting. Here are a few rules to follow:

  • Remember to always make variable names mixed case, with each word or abbreviation in the variable name capitalized.
  • Don’t use underscore characters in your variable names.
  • Abbreviate variable names only when it’s necessary.
  • Make the beginning of each variable name describe the type of data it contains.

Following these conventions will go a long way toward keeping your code concise and readable. The format for an object is

[prefixes]tag[BaseName[Suffixes]]

A prefix appears in lowercase and is used to indicate additional information, such as the scope of a variable. The tag also appears in lowercase. It is a short set of characters that indicate the type of an object. Use the BaseName to indicate what the object represents. Capitalize the first letter of each word in the BaseName. Suffixes, when used, provide additional information about the meaning of the BaseName. An example of a name for an object is

mstrFirstName

Use the prefix m to indicate that the variable appears at the module level. The tag str indicates that the variable contains a string. The BaseName FirstName indicates that the variable holds a first name. Table A.1 recommends prefixes for Access object tags.

Table A.1. Recommended Prefixes for Access Object Tags

image

image

Table A.2 lists prefix tags for standard variable types, as well as the storage space required by each.

Table A.2. Standard Variable Data Type Tags

image

Access 2003 provides the ActiveX Data Objects (ADO) Library. Table A.3 lists the recommended tags for ADO.

Table A.3. Recommended ADO Tags

image

The Access Database Engine uses objects you might need to refer to in VBA code. Table A.4 lists the Jet and Access Database Engine object types and their standard naming prefixes.

Table A.4. Jet and Access Database Engine Object/Collection Prefixes

image

image

In addition to the standard notations for variables, there are variable notations for scope and lifetime. They should be placed at the beginning of the variable, before any other prefix. Table A.5 lists the scope and lifetime prefixes.

Table A.5. Prefixes for Scope and Lifetime

image

Table A.6 lists general naming convention tags for the Navigation Pane objects.

Table A.6. Tags for Navigation Pane Objects

image

There are two sets of naming conventions you can use when naming specific database window objects: Either use the prefix for the general object prefix from the table, or supply one of the more descriptive tags listed in Table A.7.

Table A.7. Tags for Specific Navigation Pane Objects

image

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.35.178