VBA is not a case-sensitive language. However, in the real world, it is going to need to interact with case-sensitive languages. For that reason, naming standards have been adopted by the programming community to minimize the possible problems with the interaction. They are easy to remember:
Everything in lowercase
Midword capitalization
No spaces
In programming terms, any name you assign to something (such as objects, variables, and so on) is called an identifier. Let’s say you want to use My Address Book as an identifier. Using the programming conventions, you would spell it like this: myAddressBook.
To help identify the type of object something is, you begin the object name with a three-letter prefix. Table 3-1 lists the prefixes used for Access objects.
Object |
Prefix |
---|---|
Container |
con |
Document |
doc |
Field |
fld |
Form |
frm |
Group |
grp |
Index |
idx |
Macro |
mac |
Module |
mod |
Page |
pag |
Property |
pty |
Query |
qry |
Report |
rpt |
Table |
tbl |
User |
usr |
As an example, suppose you want to make myAddressBook a table. The naming convention would be tblMyAddressBook.
We will be working with these conventions all through the book.