The Leszynski naming convention (or LNC) is a variant of Hungarian notation popularized by consultant Stan Leszynski specifically for use with Microsoft Access development. 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 Since the Leszynski naming convention is a special form of Hungarian notation the same general disadvantages also apply to the Leszynski convention. Changes in database design may require wholesale renaming. For example, replacing a table with a query would involve either retaining the tbl name for the query, or going through the entire database replacing the tbl name with a query name. When transferring the database to a different DBMS, problems will arise if the target DBMS does not support CamelCase names. As every object of the same type starts with the same letter, it is not possible to navigate through the objects in a List box by typing the beginning letter.

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

ComponentDescriptionExamplePrefix(es)A lowercase letter that adds extra information to the tagp for Public variableTagA three-letter sequence indicating the object typetbl for tableBaseNameA 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 OutlookSuffix (RVBA), Qualifier (LNC)A word giving more specific information about an objectByDate – the data is sorted by date

The Basic LNC Object Prefixes ObjectTagIncomplete 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 objectszhDisplayed system objectszsProgrammatically created temporary objectsztBackup copies of objects, for later copying or reusezz

The Basic LNC Variable Prefixes Variable TypeTagLocal variable[no prefix]Local static variablesModule-level variablemPublic variable in a form or report modulepPublic variable declared in the Declarations section of a standard moduleg

The Basic LNC Database Object Tags ObjectTagClass moduleclsFormfrmForm (dialog)fdlgForm (menu)fmnuForm (message)fmsgForm (subform)fsubMacromcrModulebasModulemodQuery (any type)qryQuery (append)qappQuery (crosstab)qxtbQuery (data definition)qddlQuery (delete)qdelQuery (form filter)qfltQuery (lookup)qlkpQuery (make-table)qmakQuery (select)qry (or qsel)Query (SQL pass-through)qsptQuery (union)quniQuery (update)qupdReportrptReport (subreport)rsubTabletblMiddle TabletrelTable (attached dBASE)tdbfTable (attached Excel)txlsTable (attached FoxPro)tfoxTable (attached Lotus)twksTable (attached ODBC)todbTable (attached Paradox)tpdxTable (attached SQL Server)tsqlTable (attached text)ttxtTable (lookup)tlkpPagespge

The LNC Table Field Tags ObjectTagAutonumber (random non-sequential)idnAutonumber (replication ID)idrAutonumber (sequential)idsBinarybinBytebytCurrencycurDate/TimedtmDoubledblHyperlinkhlkIntegerintLonglngMemomemOLEoleSinglesngText (character)chrYes/No (Boolean)ysn

The LNC Tags for VBA Variables ObjectTagBooleanblnCommandBarcbrControl (generic; useful when cycling through controls on a form or report)ctlCurrencycurDatabasedbsDoubledblFormfrmIntegerintLonglngQueryDefqdfReportrptSinglesngSnapshotsnpStringstrTabletblType (user-defined)typVariantvar

The LNC Tags for Form and Report Controls +(may also be used in code referencing controls)ObjectTagAttachmentattBound object framefrbChart (graph)chtCheck box chkCombo box cboCommand buttoncmdCustom controlocxFramefraHyperlinkhlkImageimgLabellblLinelinList box lstOption button (Radio Button)optOption groupgrpPage (on a Tab control)pgePage breakbrkRectangle (shape)shpSubform/reportsubTab controltabText box txtToggle buttontglButtonbtnUnbound object framefru

Some Typical LNC Names for Database Objects, Controls and Variables Object/variable nameLNC naming elementsDescriptiontblEmployeestag + base nameA table of employee dataqupdSalestag + base nameA query that updates sales datafsubDayMaxtag + base name + qualifierA subform that shows the maximum dayintLinestag + base nameAn Integer variable to hold a value representing the number of lines in a Word tablecurSalestag + base nameA Currency variable holding a Sales valuepstrFormprefix + tag + base nameA public String variable holding a form namezztblContactsprefix + 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 Leszynski Naming Conventions for Microsoft Solution Developers LNC Renaming Add-in – A free Access add-in that automatically applies the LNC to an Access 2000, 2002 or 2003 database RVBA Conventions