NAMING CONVENTIONS FOR DATABASE OBJECTS

In Level Two of LNC, tags are required for the following Access, Jet, and SQL Server database objects:

Tables Reports
Queries/Views Report controls
Data Access Pages Macros
Forms Modules
Form and Web page controls Stored procedures

Level One also recommends that you place tags on every object name, but recognizes that non-developers may prefer to save time, effort, and complexity by leaving tags off objects where the context is obvious while viewing the Database window. Thus, Level One users are required only to place the qry tag on queries to differentiate them from tables in any combined lists, such as the Choose the Table or Query… combo box on form and report wizards. Placing tags on the other objects in the preceding list is optional.

Caution

It can be difficult to propagate name changes throughout a database. So if you're a casual user now but expect to become a developer later—and thus migrate from Level One of LNC to Level Two—it would be unwise to leave tags off any object names. Use the Level One or Level Two tags now on all objects.


Tags for Database Window Objects

Table D.4 lists the Level One tags for Database window objects. Note that only one tag exists for each object type.

Table D.4. Level One Database Window Object Tags
Object Tag
Class cls
Form frm
Data Access Page dpg
Macro mcr
Module bas
Query qry
Report rpt
Subform fsub
Subreport rsub
Table tbl
Command Bar cmb

Although Level One is the simplified naming model, it's necessary to provide tags to identify subform and subreport objects specifically. The distinction between objects and subobjects is critical for non-developers who navigate by using the Database window. Because opening subforms and subreports directly from the Database window isn't appropriate, they must be clearly identified and grouped by using tags.

Table D.5 lists the Level Two tags for Database window objects.

Table D.5. Level Two Database Window Object Tags
Object Tag
Class Module cls
Data Access Page dpg
Database Diagram dia
Form frm
Form (class module) fcls
Form (dialog) fdlg
Form (lookup table) flkp
Form (menu/switchboard) fmnu
Form (message/alert) fmsg
Form (subform) fsub
Form (wizard main) fwzm
Form (wizard subform) fwzs
Macro mcr
Macro (for form/report) m[obj]
Macro (bar menu) mmbr
Macro (general menu) mmnu
Macro (shortcut menu) mmct
Macro (submenu/drop down) mmsb
Module bas
Query/View qry
Query/View (form/report source) q[obj]
Query (append) qapp
Query (crosstab) qxtb
Query (data definition) qddl
Query (delete) qdel
Query/View (form filter) qflt
Query/View (lookup) qlkp
Query (make table) qmak
Query/View (select) qsel
Query (SQL pass-through) qspt
Query (union) quni
Query (update) qupd
Report rpt
Report (detail) rdet
Report (sub) rsub
Report (summary) rsum
Stored Procedure prc
Stored Procedure (append) papp
Stored Procedure (data definition) pddl
Stored Procedure (delete) pdel
Stored Procedure (make table) pmak
Stored Procedure (row returning) psel
Stored Procedure (union) puni
Stored Procedure (update) pupd
Table tbl
Table (linked Btrieve) tbtv
Table (linked dBASE) tdbf
Table (linked Excel) txls
Table (linked FoxPro) tfox
Table (linked Lotus 1-2-3) twks
Table (linked ODBC) todb
Table (linked Paradox) tpdx
Table (linked SQL Server) tsql
Table (linked text) ttxt
Table (lookup) tlkp
Table (many-to-many relation) trel
Table (summary information) tsum

The tags for Level Two provide rich detail about the objects and sort objects with similar attributes together. For example, lookup tables and their maintenance forms are often used over and over in multiple applications. The tags tlkp, qlkp, and flkp clearly identify these objects, making it easy for you to import them from an existing database into a new one when using the object list in Access's Import dialog. However, if a particular database doesn't warrant rich detail, you have generic tags to use as well (for example, qry instead of qsel).

In two special cases in Table D.5 (m[obj] and q[obj]), the conventions prescribe a single-character tag added to the front of the full object name (including the tag) of a related object. This situation occurs where the following two criteria are met:

  • A macro is created solely for a particular form or report, as in mfrmCust.

  • A query is created solely to serve as the record source for one particular form or report, as in qfrmCust.

Tags for Form and Report Control Objects

Table D.6 lists the Level One tags for control objects on forms and reports. These Level One control tags provide no differentiation of control type other than to distinguish labels, which don't interact with the user, from controls that can display or modify data. This level of detail isn't adequate for applications where VBA code will be written behind forms or reports, but can be a convenience with macro-centric applications.

Table D.6. Level One Form and Report Control Object Tags
Control Tag
Label lbl
Other types ctl

Don't be lulled into thinking that Level One tags are superfluous. Some expressions on forms and reports can't be evaluated when the name of the control is the same as the name of a table field in the object's recordset. For example, if the following expression is used as the control source for a report control that's named Qty in a report whose record source also contains a Qty field, the report displays #Error rather than the proper calculation:

=IIf([Qty]<100,"Low",[Qty])

The situation created here is called a circular reference, where Access doesn't know whether to evaluate [Qty] in your expression as the table field with that name or the control with that name. Giving the report control a name different from the bound field name, such as txtQty, solves the problem.

Tables D.7 and D.8 list the Level Two tags for control objects on forms, reports, and Web pages. (All control tags are three characters long.) A different tag is provided for each control type, both built-in and standard OLE controls. VBA code written behind forms and reports using this convention will reflect a control's type in its event procedure names (for example, cboState_AfterUpdate). The automatic sorting provided by this notation in the Access module design window can be very helpful during development.

Note

Controls on Data Access Pages are not necessarily objects in the Access object model, as is the case for controls on forms and reports. As a result, specific type of control used on a Web page built in Access might come from a DLL, might be one variety of a single multifaceted control type, and/or might be created with HTML statements. This structure is evident in the TypeOf column in the following table.


Table D.7. Level Two Form, Report, and Web Page Control Object Tags
Control Tag TypeOf
Bound HTML (Web page) bht MSOBoundHTML
Bound hyperlink (Web page) bhl MSOBoundHTML
Bound object frame frb BoundObjectFrame
Button (command bar) btn CommandBarButton
Chart (graph) cht ObjectFrame
Check box chk CheckBox
Check box (Web page) chk Input
Combo box cbo ComboBox
Command button cmd CommandButton
Command button (Web page) cmd Button
Custom control ocx CustomControl
Drop-down list (Web page) cbo Select
Expand (Web page) exp ExpandControl
Hotspot image (Web page) iht Img
Hyperlink hlk [**]
Hyperlink (Web page) hlk A HRef
Image img Image
Image (Web page) img Img
Label lbl Label
Label (Web page) lbl MSTheme-Label
Line lin Line
Line (Web page) lin HR
List box lst ListBox
List box (Web page) lst Select
Movie (Web page) mov Img
Office chart (Web page) cht Chart
Office pivot table (Web page) pvt PivotTable
Office spreadsheet (Web page) sht Spreadsheet
Option button opt OptionButton
Option button (Web page) opt Input
Option group grp OptionGroup
Option group (Web page) grp FieldSet
Page (tab) pag Page
Pages (tab) pags Pages
Page break brk PageBreak
Record navigation (Web page) nav RecordNavigationControl
Rectangle shp Rectangle
Rectangle (Web page) shp MicrosoftAccessRectangle
Scrolling text (Web page) mqe Marquee
Section sec Section
Subform/Subreport sub Subform
Tab tab TabControl
Text box txt TextBox
Text box (Web page) txt TextArea
Toggle button tgl ToggleButton
Unbound object frame fru ObjectFrame

[**] Hyperlink is actually a ComboBox, CommandButton, Image, Label, or Textbox

All control tags are three characters long.

Some conventions try to catalog or create tags for third-party OLE controls. Such an effort is beyond the scope of this appendix—I take responsibility here only for helping you use controls that are part of an Access developer's standard tool set or are created by my company. If you're interested in tags for third-party controls, a starting point is the document “Microsoft Consulting Services Naming Conventions for VB” on the Microsoft Developer Network CD subscription.

Table D.8. Form and Report ActiveX Control Object Tags
Control Tag Source File Name
Animation ani ODE Comct232.ocx
Calendar cal Access Mscal.ocx
Calendar kcal Kwery Kccal32.ocx
Clock kclk Kwery Kcclok32.ocx
CommonDialog cdlg ODE Comdlg32.ocx
Gauge kgau Kwery Kcgage32.ocx
ImageList ilst ODE Comctl32.ocx
ListView lvw ODE Comctl32.ocx
Preview kpvw Kwery Kcprvw32.ocx
ProgressBar pbr ODE Comctl32.ocx
RichTextBox rtf ODE Richtx32.ocx
Slider sld ODE Comctl32.ocx
StatusBar sbr ODE Comctl32.ocx
TabStrip tabs ODE Comctl32.ocx
Toolbar tbr ODE Comctl32.ocx
TreeView tvw ODE Comctl32.ocx
Up/Down upc ODE Comct232.ocx
Wheel kwhl Kwery Kcwhl32.ocx

Prefixes for Database Objects

The following list describes the database object prefixes and their usage. With the exception of zz for backup copies of objects, these prefixes are Level Two (that is, developer) elements only:

  • _ (underscore) Use this prefix for objects that are incomplete and under development. When the Database window is sorted by object name, this prefix sorts objects to the top, where they're immediately recognized as unfinished and unusable. When the object is ready for testing or deployment, remove the underscore. This prefix isn't used with form and report controls.

  • zh Use this prefix to denote system objects, which are for use by developers and application code only and should be hidden from users by default. In LNC terms, system objects provide the infrastructure for an application but aren't meant for user interaction. For example, you would use this prefix on a form's hidden text box that's used to compute a value, or on a hidden table that provides message strings to your VBA code.

Note

Access has its own prefix—USys—with a similar meaning. Items prefixed with USys aren't for user interaction and aren't displayed in the Database window by default. In past versions of Access, it was necessary to use USys instead of zh to prevent the display of system objects in the Database window. Beginning with Access version 8.0 (Access 97), you can use the zh prefix combined with setting the object's Hidden property to true to achieve this result. If the system object shouldn't be hidden, use the zs prefix instead.


  • zs Use this prefix to denote displayed system objects, which are for use by developers and application code only but should be displayed in the Database window. If the system object should be hidden, use the zh prefix instead.

  • zt Use this prefix for temporary objects that are created programmatically. For example, a query written out from VBA code, used in code, and then deleted by the code would have a zt prefix. Any database object labeled with zt showing in the Database window should be deleted before each repair and compact of a database because by definition it's probably left over from an abnormally terminated process that didn't clean up after itself.

  • zz This prefix denotes backup copies of objects that you keep in the database window for reference or possible reuse. Items with this prefix should be periodically reviewed to determine their value and deleted if not needed.

Note

Most of these database object prefixes use z as the first character. Database objects with such prefixes sort to the bottom of the Database window, below the user-oriented objects that are accessed more frequently.


Using Menu Macros

Menu macros behave differently than standard macros; as a result, they fall under separate guidelines when creating their names. Menu macros are used either for bar menus or for shortcut menus.

If you use the Menu Builder add-in, your custom menu macros will be assigned names when the builder saves your menu design. You'll have little control over anything but the tag and base name for the primary (bar) menu. If you use the LNC convention of mmnuName for your menu macro, the builder will create an entire tree of macros beginning with the string you enter—for example,

mmnuMain
mmnuMain_File
mmnuMain_File_Export

If you prefer to create and name menus yourself, you can use a similar convention but with more explicit tags. Bar menus should be prefixed with mmbr, submenus (drop down) with mmsb, and shortcut menus with mmct. Detailed tags like this will help greatly when you're selecting from a list of menus to assign to the MenuBar or ShortcutMenuBar property of a form. This convention also sorts menus by type in the Database window. The preceding macro listing, if produced manually rather than with the builder, would look like this:

mmbrMain
mmctMainFile
mmsbMainFile
mmsbMainFileExport

Because any saved submenu macro can be selected as the primary object in a shortcut menu, this convention gives you the flexibility to create component submenus (such as mmsbMainFileExport), which can be called from both multiple bar menus and multiple shortcut menus and thus reused.

Note

Menu macros were used in earlier versions of Access. If you are using Access 97 or 2000, you should be using the newer command bar technology instead.


Database Object Name Examples

Table D.9 shows examples of database objects, applying the various conventions shown thus far.

Table D.9. Database Object Naming Convention Examples
Object Description
zhtxtUser Hidden system text box
mfrmCust Macro for form
zttfoxCustHist Temporary FoxPro attachment
qupdCustBal_Dlr Update customers that are dealers
trelCustAddrPhone Link many addresses to many phones

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

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