
Home
General Guidelines:
Naming of Controls on
Forms and Reports
by A.D. Tejpal
- For controls referenced in code or expressions, the names
should not be the default names such as "Text13". It is best to
modify the default name to something meaningful that eases maintenance of
application.
- An unbound or calculated control should not have its
name identical to any of the fields contained in the record source. As a
standing precaution, suitable prefix like Txt (or txt), Cbo (or cbo) etc
should be used while naming such controls.
- It is perfectly Ok if the name of a pure bound control
is the same as its control source (unless, for some reason, you need a
different name for the bound control - see para 4 below). It can also
prove convenient in readily distinguishing the bound controls from others.
However, in such an arrangement, care has to be exercised on following
lines:
- If the role of an erstwhile bound control bearing a
name identical to its control source is subsequently changed to that of
an unbound or calculated control, its name should be modified
simultaneously (including suitable prefix as per 2 above) so as to
differentiate it from field names.
- If the control source of a bound control is
subsequently changed, its name should be changed simultaneously, matching
the new control source.
- There is no objection however, to rename even bound
controls, say by prefixing with Txt (or txt), Cbo
(or cbo) etc. if the developer is keen to do so. In such a case, care
should be taken to use the actual field name (and not the control name)
while using the content in aggregate expressions in calculated controls
e.g. =Sum([FieldName]). It would also be
desirable to give meaningful names to such calculated controls e.g.
txtTotal, or txtAvg etc.
- For a control bearing the name of a particular field
in record source, NEVER bind it to some other field.
- Note - In allowing the names of bound controls to be identical
with the control source, if the developer is not confident enough that the
discipline envisaged in para 3 (a) & (b) above would be strictly
observed, it might prove safer to rename all such controls in the
beginning itself, as per para 4 above. In order to make such a task less
taxing, suitable tool like Arvin Meyer's FixNames
utility can be used if desired.
A.D.Tejpal
