Naming control labels and their captions
June 20th, 2008 Posted in 6. MS AccessYou might notice that each of the data fields has a Label control and a Text Box control. Normally, the label’s Caption property is the same as the text box’s Name property. The text box’s Name property is usually the same as the table’s field name—shown in the Control Source property. Sometimes, the label’s Caption is different because a value was entered into the Caption property for each field in the table.
When creating controls on a form, it’s a good idea to use standard naming conventions when setting the control’s Name property. Name each control with a prefix followed by a meaningful name that you’ll recognize later (for example, txtTotalCost, cboState, lblTitle). Table 35-2 shows the naming conventions
for form and report controls. You can find a very complete, well-established naming convention online by searching for “Reddick Naming Convention.”
TABLE 35-2
Form/Report Control Naming Conventions
frb Bound Object frame
cht Chart (Graph)
chk Check Box
cbo Combo Box
cmd Command Button
ocx ActiveX Custom Control
det Detail (section)
gft[n] Footer (group section)
fft Form Footer section
fhd Form Header section
ghd[n] Header (group section)
hlk Hyperlink
img Image
lbl Label
lin Line
lst List Box
opt Option Button
grp Option Group
pge Page (tab)
brk Page break
pft Page Footer (section)
phd Page Header (section)
shp Rectangle
rft Report Footer (section)
rhd Report Header (section)
sec Section
sub Subform/Subreport
tab Tab Control
txt Text Box
tgl Toggle Button
fru Unbound Object Frame
The first two properties, Name and Control Source, are set to Description.
The Name is simply the name of the field itself. When a control is bound to a field, Access automatically assigns the Name property to the bound field’s name. Unbound controls are given names such as Field11 or Button13. However, you can give the control any name you want.
With bound controls, the Control Source property is the name of the table field to which the control is bound. In this example, Description refers to the field with the same name in tblProducts. An unbound control has no control source, whereas the control source of a calculated control is the actual expression for the calculation, as in the example =[SalePrice] - [Cost].