Leszynski naming convention explained

The Leszynski naming convention (or LNC) is a variant of Hungarian notation popularized by consultant Stan Leszynski specifically for use with Microsoft Access development.[1] Although the naming convention is nowadays often used within the Microsoft Access community, and is the standard in Visual Basic programming, it is not widely used elsewhere.

The conventions are derived from an earlier set of conventions, the Leszynski/Reddick naming conventions, originally developed in 1992 by Greg Reddick. Eventually, Leszynski and Reddick had different ideas about how the conventions should be developed, and split into two separate sets of conventions, the other being the RVBA Conventions.

As in all Hungarian notations, it uses prefixes (called tags) to indicate the type of objects and database development fields. The general structure of Hungarian notation (named after Charles Simonyi's native country) is to break down object names into the following elements:[prefix(es)][tag]BaseName[Suffix/Qualifier]The tags are lower case and the object name is camel case. Spaces and underscores are not used.

Advantages

Since the Leszynski naming convention is a special form of Hungarian notation the same general advantages also apply to the Leszynski convention.

The use of distinctive prefixes makes your database self-documenting; when you see frmSales in VBA code, you will know that it references a form, and when you see curSales you will know that it is a Currency variable. When selecting a query from a drop-down list, you will know that a query starting with qmak is a make-table query, while one starting with quni is a union query. This information will allow you to avoid errors such as using the SetFocus method (a control method) with a field, or trying to open a table.

Disadvantages

Elements

The elements of the naming convention are described in the following table.

ComponentDescriptionExample
Prefix(es)A lowercase letter that adds extra information to the tagp for Public variable
TagA three-letter sequence indicating the object typetbl for table
BaseNameA word or two describing the object. If several words are used, each starts with a capital letter, and there are no spaces between themOutlookContacts – contacts imported from Outlook
Suffix (RVBA), Qualifier (LNC)A word giving more specific information about an objectByDate – the data is sorted by date

The Basic LNC Object Prefixes

ObjectTag
Incomplete objects, backup objects, or objects that are under development_ or – (In some versions of Access, dashes sort to the beginning of the database object list.)
Hidden system objectszh
Displayed system objectszs
Programmatically created temporary objectszt
Backup copies of objects, for later copying or reusezz

The Basic LNC Variable Prefixes

Variable TypeTag
Local variable[no prefix]
Local static variables
Module-level variablem
Public variable in a form or report modulep
Public variable declared in the Declarations section of a standard moduleg

The Basic LNC Database Object Tags

ObjectTag
Class modulecls
Formfrm
Form (dialog)fdlg
Form (menu)fmnu
Form (message)fmsg
Form (subform)fsub
Macromcr
Modulebas
Modulemod
Query (any type)qry
Query (append)qapp
Query (crosstab)qxtb
Query (data definition)qddl
Query (delete)qdel
Query (form filter)qflt
Query (lookup)qlkp
Query (make-table)qmak
Query (select)qry (or qsel)
Query (SQL pass-through)qspt
Query (union)quni
Query (update)qupd
Reportrpt
Report (subreport)rsub
Tabletbl
Middle Tabletrel
Table (attached dBASE)tdbf
Table (attached Excel)txls
Table (attached FoxPro)tfox
Table (attached Lotus)twks
Table (attached ODBC)todb
Table (attached Paradox)tpdx
Table (attached SQL Server)tsql
Table (attached text)ttxt
Table (lookup)tlkp
Pagespge

The LNC Table Field Tags

ObjectTag
Autonumber (random non-sequential)idn
Autonumber (replication ID)idr
Autonumber (sequential)ids
Binarybin
Bytebyt
Currencycur
Date/Timedtm
Doubledbl
Hyperlinkhlk
Integerint
Longlng
Memomem
OLEole
Singlesng
Text (character)chr
Yes/No (Boolean)ysn

The LNC Tags for VBA Variables

ObjectTag
Booleanbln
CommandBarcbr
Control (generic; useful when cycling through controls on a form or report)ctl
Currencycur
Databasedbs
Doubledbl
Formfrm
Integerint
Longlng
QueryDefqdf
Reportrpt
Singlesng
Snapshotsnp
Stringstr
Tabletbl
Type (user-defined)typ
Variantvar

The LNC Tags for Form and Report Controls

(may also be used in code referencing controls)
ObjectTag
Attachmentatt
Bound object framefrb
Chart (graph)cht
Check box chk
Combo box cbo
Command buttoncmd
Custom controlocx
Framefra
Hyperlinkhlk
Imageimg
Labellbl
Linelin
List box lst
Option button (Radio Button)opt
Option groupgrp
Page (on a Tab control)pge
Page breakbrk
Rectangle (shape)shp
Subform/reportsub
Tab controltab
Text box txt
Toggle buttontgl
Buttonbtn
Unbound object framefru

Some Typical LNC Names for Database Objects, Controls and Variables

Object/variable nameLNC naming elementsDescription
tblEmployeestag + base nameA table of employee data
qupdSalestag + base nameA query that updates sales data
fsubDayMaxtag + base name + qualifierA subform that shows the maximum day
intLinestag + base nameAn Integer variable to hold a value representing the number of lines in a Word table
curSalestag + base nameA Currency variable holding a Sales value
pstrFormprefix + tag + base nameA public String variable holding a form name
zztblContactsprefix + tag + base nameA backup Contacts table, for copying and filling with imported data

References

Part of this article is based on Helen Feddema's book, Expert One-on-One Microsoft Access Application Development, Wiley, .

External links

Notes and References

  1. Web site: Naming Conventions for Microsoft Access (Archived Microsoft Access Content). MSDN.Microsoft.com.