Learn Access 2003 VBA with The Smart Method
284
www.LearnAccessVBA.com
4: Access object naming
4-1
Prefix objects with the following letters in lower case:
Object
Prefix
Table
No prefix
Query
qry
Form
frm
Report
rpt
Macro
mcr
Module
mod
Example: frmFilm.
5: Form control naming
5-1
Use generally accepted three-letter standard prefixes for all form controls. Some of the more
common prefixes are:
Prefix
Object Type
Example
cbo Combo Box and Drop Down List
Box
cboEnglish
chk Checkbox
chkReadOnly
cmd Command Button
cmdOK
ctr Control (when specific type is
unknown)
ctrCurrent
dat Data control
datFilm
dir Directory list box
dirSource
dlg Common Dialog Control
dlgFileOpen
frm Form
frmEntry
fra Frame
fraStyle
img Image
imgIcon
lbl Label
lblHelpMessage
lin Line
linVertical
lst List Box
lstPolicyCodes
mnu Menu
mnuFileOpen
opt Option Button
optRed
pg_0002
Appendix A: The Rules
© 2007 The Smart Method Ltd
285
ole OLE Control
oleWorksheet
pic Picture
picHotel
spn Spin Control
spnPages
txt Text Box
txtLastName
tmr Timer
tmrAlarm
6: Variable naming
6-1
Module scoped variables must be prefixed with the letter m and globally scoped variables must
be prefixed with the letter g.
Note that, despite this standard, it is nearly always poor programming practice to use any globally
visible variables in an application (note that this rule does not apply to globally visible constants that
are extremely useful).
mstrCustomerName ‘ Module level
strCustomerName ‘ Local to sub
gstrApplicationLanguage ‘ Globally visible
6-2
Use generally accepted three-letter variable prefixes.
Microsoft publish recommended three-letter variable prefixes in their MSDN library and these are
generally accepted by professional programmers.
Some of the more common prefixes are:
Data Type
Prefix
String
str
Long integer
lng
Boolean
bln
Currency
cur
Double
dbl
Variant
vnt (var also acceptable)
Date and Time
dat (dtm also acceptable)
The alternative prefixes for Variant and Date and Time above are so commonly used that both can be
allowed as similies within code.
Early code was often written with one letter variable type prefixes (such as s for string). There’s
even examples in wizard-generated code of two-letter variable prefixes (such as st for string) but
neither style is often seen today.