Previous Page TOC Index Home


B

Naming Conventions

This appendix provides suggestions for the naming of variables and other database objects. The suggested standards are based on the Leszynski Naming Conventions (LNC) for Microsoft Access. If you want more information about these standards or want to obtain the full copy provided by Kwery Corporation, contact Kwery via the order line at 1-800-ATKWERY or on the product information line at 206-644-7830. Kwery can also be reached via CompuServe at 71573,3261 or via fax at 206-644-8409.

When creating variable names, it is important for you to make the type and intended use of each variable clear and self-documenting. Here are a few rules to follow:

Adherence to these conventions will go a long way toward keeping your code concise and readable. Table B.1 recommends prefixes for Access object tags.

Prefix

Control Type

Example

app

Application

appInfoBase

chk

CheckBox

chkReadOnly

cbo

ComboBox

cboLanguages

cmd

CommandButton

cmdRefreshTable

ctl

Control

ctlAny

ctls

Controls

ctlsAll

ocx

CustomControl

ocxCalendar

dcm

DoCmd

dcmOpenForm

frm

Form

frmDataEntryView

frms

Forms

frmsClientsAndOrders

img

Image

imgHeadShot

lbl

Label

lblShowAllCheckBox

lin

Line

linDivider

lst

ListBox

lstLastTenSites

bas

Module

basErrorControl

ole

ObjectFrame

oleWorksheet

opt

OptionButton

optReadOnly

fra

OptionGroup (frame)

fraColorSchemes

brk

PageBreak

brkTopOfForm

pal

PaletteButton

palBackgroundColor

prps

Properties

prpsActiveForm

shp

Rectangle

shpHidableFrame

rpt

Report

rptOrders

rpts

Reports

rptsTodaysChanges

scr

Screen

scrSecondSplashScreen

sec

Section

secOrderDetail

fsub

Subform

fsubBillableHours

rsub

SubReport

rsubTopFiveSales

txt

TextBox

txtAdditionalNotes

tgl

ToggleButton

tglShowFormatting

Table B.2 provides prefix tags for standard variable types, as well as the storage space required by each.

Prefix

Data Type

Storage

Example

byt

Byte

1 byte

byteArray

f

Boolean

2 bytes

fSecurityClear

int

Integer

2 bytes

intLoop

lng

Long

4 bytes

lngEnv

sng

Single

4 bytes

sngValue

dbl

Double

8 bytes

dblValue

cur

Currency

8 bytes

curCostPerUnit

dat

Date and Time

8 bytes

datStartTime

obj

Object

varies

objActiveObject

str

String

1 byte per character

strFirstName

stf

String (fixed length)

10 bytes + 1 byte per char

stfSocNumber

var

Variant

16 bytes + 1 byte per char

varInput

The Jet Database engine utilizes objects that you might need to refer to in VBA code. Table B.3 lists the DAO object types and their standard naming prefixes.

Prefix

Object Type

cnt

Container

cnts

Containers

db

Database

dbs

Databases

dbe

DBEngine

doc

Document

docs

Documents

err

Error

errs

Errors

fld

Field

flds

Fields

grp

Group

grps

Groups

idx

Index

idxs

Indexes

prm

Parameter

prms

Parameters

pdbe

PrivDBEngine

prp

Property

prps

Properties

qry (or qdf)

QueryDef

qrys (or qdfs)

QueryDefs

rst

Recordset

rsts

Recordsets

rel

Relation

rels

Relations

tbl (or tdf)

TableDef

tbls (or tdfs)

TableDefs

usr

User

usrs

Users

wrk

Workspace

wrks

Workspaces

In addition to the standard notations for variables, there are variable notations for scope and lifetime. These should be placed at the beginning of the variable, before any other prefix. Table B.4 lists the scope and lifetime prefixes.

Prefix

Description

(none)

Local variable, procedure-level lifetime

s

Local variable, program-level lifetime (static variable)

m

Private (module) variable, program-level lifetime

g

Public (global) variable, program-level lifetime

Table B.5 provides general naming convention tags for the Database window objects.

Prefix

Object Type

tbl

Table

qry

Query

frm

Form

rpt

Report

mcr

Macro

bas

Module

There are two sets of naming conventions you can use when naming specific Database window objects: Either use the prefix for the general object prefix from the table or supply one of the more descriptive tags listed in Table B.6.

Prefix

Suffix

Object Type

tlkp

Lookup

Table (lookup)

qsel

(none)

Query (select)

qapp

Append

Query (append)

qxtb

XTab

Query (crosstab)

qddl

DDL

Query (DDL)

qdel

Delete

Query (delete)

qflt

Filter

Query (filter)

qlkp

Lookup

Query (lookup)

qmak

MakeTable

Query (make table)

qspt

PassThru

Query (SQL pass-through)

qtot

Totals

Query (totals)

quni

Union

Query (union)

qupd

Update

Query (update)

fdlg

Dlg

Form (dialog)

fmnu

Mnu

Form (menu)

fmsg

Msg

Form (message)

fsfr

Subform

Form (subform)

rsrp

SubReport

Form (subreport)

mmnu

Mnu

Macro (menu)

Previous Page TOC Index Home