Copyright: AccessPRO Building Tools Version 1.2
Citation: Mississauga Software Technologies ©1995


Contents
AccessPRO Building Tools Contents

AccessPRO Building Tools Version 1.2 was developed to help Microsoft® Access® 2.0 developers create better quality Access applications in a shorter time. There a two types of tool sets available; form/report building tools and Access Basic code building tools.

Form and Report Builders

Color Builder

Control Nudgers

Name Builder

StatusBarText, InputMask, and Format Builders

Code Builders

Beautify Code

Code Snippet

Comment Code

DoCmd Builder

MsgBox Builder

Un-Comment Code

Variable Type Tag

AccessPRO Building Tools Options

Opening the options form

Common Questions and Answers

I get an error when I try to install AccessPRO Building Tools.

How do I get rid of the standard Access builders like the color builder

What do I get with the registered version

How do I order AccessPRO Building Tools

Appendix

MSACC20.INI File Entries

The Leszynski/Reddick Guidelines for Access 1.x, 2.x

License and Warranty

For Help on Help, Press F1


Name Builder

See Also

Description

The Name Builder sets the selected control name to a value that consists of the control type tag and another relevant characteristic such as the bound field name. When controls are added to a form or report they are given names like ‘Text13’ which really doesn’t mean much. The Name Builder will assign a name like ‘txtCustomerName’ which is easier to understand. A developer can quickly see that this control is a text box that is bound to field ‘CustomerName’. Using a standard naming convention has always been a good idea but has proven to be time consuming and something that really doesn’t get done. With the Name Builder a developer can quickly implement a standard naming convention without hardly any effort. Your own code will be easier to read especially when you look at months from now. Other developers that inherit your applications will also appreciate a standard naming convention. The AccessPRO Name Builder defaults are based on the Leszynski/Reddick naming conventions originally published in the August 1993 issue of Smart Access, published by Pinnacle Publishing Inc. (Kent, WA)

A naming standard can also be easily implemented in existing applications as well. Any code that is attached to a control event will remain attached to that control after it is renamed using the Name Builder. All instances of the old control name in the form or report code will be replaced with the new control name in the form or report’s code module. Often you may want to bypass this feature if you know there is no code attached to the control. To bypass the control name find and replace simply hold down the Shift key while pressing the builder button.

Using the Name Builder

•	Press the builder button for the controls’ Name property.

•	The control will be renamed with the standard control type tag defined on the AccessPRO Building Tools Options form.

Tips and Tricks

•	To set all the control and section names at once, select the Name property of a form or report section.

•	Hold the Shift key down to bypass the control name find and replace in any code attached to the form or report.

Setting the Default Control Name Tags

•	Open the AccessPRO Building Tools Options formOptions.

•	Select the Control Names tab to set the control colors.


Color Builder

See Also

Description

The Color Builder allows you to select a Windows® system color, a custom color, or the default color defined for the control. The Color Builder will optionally set all default color properties for the selected control, or all the colors for all of the controls on the form or report. Windows® system colors are defined in Control Panel and are specific to the personal tastes of the user.

By setting your control colors to Windows® system colors, your application will look like the user wants it to, not how you have hard coded the colors into the application.

Using the Color Builder

•	Press the Builder button for the controls Forecolor, Backcolor, or Bordercolor property

•	The control name and color property will be shown in the caption of the Color Builder form.

•	Select the Update All Color Properties checkbox if you want all the color properties of the control to be set.

•	Select OK to accept the current default color or select an different Windows® System color or Other custom color.

Tips and Tricks

•	To set all the control and section colors at once, select the BackColor property a form or report section.

•	You can set the color properties of several controls at once by selecting them all.

•	Press Apply to see how the color will actually look before you press the OK button.

•	Pressing Cancel will restore the original color.

Setting the Default Color

•	Open the AccessPRO Building Tools Options form.

•	Select the Control Colors tab to set the control colors.


Control Nudgers
Left, Right, Top, Width Control Nudgers

See Also

Description

Control Nudgers allow to move and size control one pixel at a time. This is useful for lining things up ‘just right’ and for creating 3D effects.

Using the Control Nudger Builder

•	Press the builder button for the controls’ Left, Right, Top or Width property.

•	The control will be moved or sized one pixel for each press of the builder button.

Tips & Tricks

•	To move the control in the other direction, hold down the Shift key.

•	To move the edge of the control and resize it at the same time, hold down the Alt key.


StatusBarText, InputMask, and Format Builders
StatusBarText, InputMask and Format Builders

See Also

Description

The StatusBarText, InputMask, and Format Builders copy the property from the field definition of the form or reports’ recordsource. When controls are added to a bound form or report and are dragged from the field list, Access will automatically add these properties. Often during the development process, the field properties are not set before the form is created or the properites are changed. These tools will allow you to quickly update your form with a minimum of effort.

Using the Control Nudger Builder

•	Press the builder button for the controls’ StatusBarText, InputMask, or Format property.

•	The property will be retrieved from the RecordSource’s field definition.

Tips & Tricks

•	Do a multiple select to set the property of several controls at once.


StatusBarText See Also
See Also:

NameBuilder

Color Builder

Control Nudgers


DoCmd Builder

See Also

Description

The DoCmd builder will quickly construct or edit a DoCmd statement by selecting the action arguments from pull down lists. There is no need to remember the correct syntax of the statement or the number of commas to put in. Typing errors are reduced because arguments like form or query names are selected directly from a list.

Using the DoCmd Builder

•	While in a code window, locate the cursor on an existing DoCmd statement or where you  want to insert a new statement.

•	Press the Builder button on the Module Menu bar or from the quick menu on a right mouse click.

•	Select DoCmd Builder from the list of code builders.

•	Select the Action and all the required action arguments on the DoCmd builder form.

•	Press OK the paste the statement into you code.

Tips & Tricks

•	Arguments that are in bold are required.

•	When an argument requires a file name, double-click on the argument to get a 'file open' dialog box.

•	You don't need to select an argument from the list. You may type a variable name into the combo box.

•	If you use the same DoCmd statement often, consider adding it in your Code Snippet library.

•	This builder works just as good with existing DoCmd statements as with new statements.

•	Press the Help button to get Access help on the current DoCmd action.


MsgBox Builder

See Also

Description

The MsgBox (Message Box) builder will quickly construct or edit a MsgBox statement or function. You won't have to call up the help file every time you write a message box statement to remember what the value is for a query icon.

Using the MsgBox Builder

•	While in a code window, locate the cursor on an existing MsgBox statement or where you  want to insert a new statement.

•	Press the Builder button on the Module Menu bar or from the quick menu on a right mouse click.

•	Select MsgBox Builder from the list of code builders.

•	Enter the caption, message text. Select the number of buttons, icon style, and default button on the MsgBox Builder form.

•	Press OK the paste the statement into you code.

Tips & Tricks

•	By pressing the Try It button you can get an idea of what the message box will look like at run time. You can also see what the return value of each button pressed will be.

•	You don't need to enter the message or caption text. You may type a variable name into the combo box. Quotes will be added or removed automatically.

•	If you use the same MsgBox statement often, consider adding it in your Code Snippet library.

•	This builder works just as good with existing MsgBox statements as with new statements.

•	Press the Help button to get Access help on the MsgBox statement.


Code Snippet

See Also

Description

Code Snippet is a library of commonly used code segments. You can quickly paste statements or complete functions into your applications. Never type the code for opening a recordset again!

Saving Code Snippets

•	While in a code window select the code snippet you want to save.

•	Press the Builder button  on the Module Menu bar or from the quick menu on a right mouse click.

•	Select Code Snippet from the list of code builders.

•	Press the Add... button on the Code Snippet form.

•	Enter a unique description for the code snippet.

•	Press OK the save the new code.

Pasting Code Snippets

•	While in a code window place the cursor where you  want to insert the code snippet.

•	Press the Builder button on the Module Menu bar or from the quick menu on a right mouse click.

•	Select Code Snippet from the list of code builders.

•	Select a Code Snippet from the list on the Code Snippet form.

•	Press OK the paste the statement into you code.

Tips & Tricks

•	You can double-click on the Code Snippet from the list to quickly paste it into your code.

•	Use the Apply button to paste the code in your form without closing the Code Snippet form. By doing this you can paste many code snippets at one time at different locations in your code.

•	You can keep the Code Snippet form open. If you close the original form the Code Snippet will be copied to the clipboard.

Editing Code Snippets

•	Open the AccessPRO Building Tools Options form

•	Select the Code Snippet tab to edit the Code Snippets.


Comment Code

See Also	Example

Description

The Comment Code builder comments the selected lines of code.

Using the Comment Code Builder

•	While in a code window select the code you want commented.

•	Press the Builder button on the Module Menu bar or from the quick menu on a right mouse click.

•	Select Comment Code from the list of code builders.

Tips & Tricks

•	Use this to quickly bypass questionable code while you are developing and application.


Comment Code Example

Here is a section of code before the Comment Code builder was used.

If pintFormOrReport Then

  If intControlType = 88 Then

    intSec = MyGetSectionNumber(Forms(pstrObjectName), pstrCtlName)

  Else

    Set ctl = Forms(pstrObjectName)(pstrCtlName)

  End If

Else

  If intControlType = 88 Then

    intSec = MyGetRepSectionNum(Reports(pstrObjectName), pstrCtlName)

  Else

    Set ctl = Reports(pstrObjectName)(pstrCtlName)

  End If

End If

The second If...Then code section was commented out with one selection.

If pintFormOrReport Then

 ‘If intControlType = 88 Then

 ‘  intSec = MyGetSectionNumber(Forms(pstrObjectName), pstrCtlName)

 ‘Else

 ‘  Set ctl = Forms(pstrObjectName)(pstrCtlName)

 ‘End If

‘Else

  If intControlType = 88 Then

    intSec = MyGetRepSectionNum(Reports(pstrObjectName), pstrCtlName)

  Else

    Set ctl = Reports(pstrObjectName)(pstrCtlName)

  End If

End If


Beaytify Code See Also
See Also:

Comment Code

Un-Comment Code


Un-Comment Code

See Also	Example

Description

The Comment Code builder removes the comments from selected lines of code.

Using the Comment Code Builder

•	While in a code window select the code you want commented..

•	Press the Builder button on the Module Menu bar or from the quick menu on a right mouse click.

•	Select Un-Comment Code from the list of code builders.

Tips & Tricks

•	Use this to quickly add back the code you commented using the Comment Code builder.


Un-Comment Code Example

Here is a section of code before the Un-Comment Code builder was used.

If pintFormOrReport Then

  ‘If intControlType = 88 Then

  ‘  intSec = MyGetSectionNumber(Forms(pstrObjectName), pstrCtlName)

  ‘Else

  ‘  Set ctl = Forms(pstrObjectName)(pstrCtlName)

  ‘End If

‘Else

  If intControlType = 88 Then

    intSec = MyGetRepSectionNum(Reports(pstrObjectName), pstrCtlName)

  Else

    Set ctl = Reports(pstrObjectName)(pstrCtlName)

  End If

End If

The second If...Then code section was un-commented out with one selection.

If pintFormOrReport Then

 If intControlType = 88 Then

   intSec = MyGetSectionNumber(Forms(pstrObjectName), pstrCtlName)

 Else

   Set ctl = Forms(pstrObjectName)(pstrCtlName)

 End If

Else

  If intControlType = 88 Then

    intSec = MyGetRepSectionNum(Reports(pstrObjectName), pstrCtlName)

  Else

    Set ctl = Reports(pstrObjectName)(pstrCtlName)

  End If

End If


Comment Code See Also:
See Also:

Un-Comment Code

Code Snippet

Beautify Code


MsgBox Builder See Also
See Also:

DoCmd Builder

Code Snippet


Beautify Code

See Also	Example

Description

The Beautify Code builder correctly indents all the conditional statements in the selected Access Basic code.

Using the Beautify Code Builder

•	While in a code window select the code you want beautify.

•	Press the Builder button on the Module Menu bar or from the quick menu on a right mouse click.

•	Select Beautify Code from the list of code builders.

Tips & Tricks

•	The number of spaces indented is based on View, Options..., Module Design, Tab Stop Width setting.


Builder Button

 Select the property from the property list and the builder button will appear.


DoCmd See Alse
See Also:

Code Snippet

MsgBox Builder


Beautify Code Example

Here is an example of what the Beautify code command does. Before using Beautify Code, a code sample may look like this:

If pintFormOrReport Then

   If intControlType = 88 Then

  intSec = MyGetSectionNumber(Forms(pstrObjectName), pstrCtlName)

  Else

Set ctl = Forms(pstrObjectName)(pstrCtlName)

  End If

Else

  If intControlType = 88 Then

 intSec = MyGetRepSectionNum(Reports(pstrObjectName), pstrCtlName)

  Else

 Set ctl = Reports(pstrObjectName)(pstrCtlName)

  End If

    End If

This is the same code after Beautify Code was done:

If pintFormOrReport Then

  If intControlType = 88 Then

    intSec = MyGetSectionNumber(Forms(pstrObjectName), pstrCtlName)

  Else

    Set ctl = Forms(pstrObjectName)(pstrCtlName)

  End If

Else

  If intControlType = 88 Then

    intSec = MyGetRepSectionNum(Reports(pstrObjectName), pstrCtlName)

  Else

    Set ctl = Reports(pstrObjectName)(pstrCtlName)

  End If

End If

The beautified code is much easier to read, understand, and debug.


Options

Description

The AccessPRO Building Tools Options form is used to define the default settings for the code and control property builders.

Opening the Form

•	Select File, Add-ins, Building Tools....

OR

•	Select File, Add-ins, Add-In Manager, AccessPRO Building Tools, Customize .


Code Snippet See Also
See Also:

Opening the options form


Color Builder See Also
See Also:

NameBuilder

Opening the options form

Control Nudgers

StatusBarText, InputMask, and Format Builders


ToolBar Builder Button


Un-Comment Code See Also
See Also

Comment Code


MSACC20.INI File Entries

The following entries are required in the INI file that Access is using for AccessPRO Building Tools to work correctly. This file is usually called MSACC20.INI and is located in your Windows® directory.

[Menu Add-Ins]

&Building Tools...==APCustomize()

[Libraries]

Apbldtls.mda=rw

[Property Wizards]

APBackColorBuilder=BackColor,AccessPRO Color Builder,APBackColorBuilder,rw

APBorderColorBuilder=BorderColor,AccessPRO Color Builder,APBorderColorBuilder,rw

APForeColorBuilder=ForeColor,AccessPRO Color Builder,APForeColorBuilder,rw

APNudgeHeight=Height,Nudge Height,APNudgeHeight,rw

APNudgeLeft=Left,Nudge Left,APNudgeLeft,rw

APNudgeTop=Top,Nudge Top,APNudgeTop,rw

APNudgeWidth=Width,Nudge Width,APNudgeWidth,rw

APStatusBarBuilder=StatusBarText,Status Bar Text Builder,APStatusTextBuilder,rw

APFormatBuilder=Format,AccessPRO Format Builder,APFormatBuilder,rw

APInputMaskBuilder=InputMask,AccessPRO Input Mask Builder,APInputMaskBuilder,rw

APNameBuilder=Name,Name Builder,APNameBuilder,rw

APVarTypeTag=Module,Variable Type Tag,APFixVarType,rw

APBeautifyCode=Module,Beautify Code,APBeautifyCode,rw

APCodeSnippet=Module,Code Snippet,APCodeSnippet,rw

APCommentCode=Module,Comment Code,APCommentCode,rw

APUnCommentCode=Module,Un-Comment Code,APUnCommentCode,rw

APMsgBoxBuilder=Module,MsgBox Builder,APMsgBoxBuilder,rw

APDoCmdBuilder=Module,DoCmd Builder,APDoCmdBuilder,rw


Variable Type Tag

See Also	Example

Description

The Variable Type Tag Builder adds the correct variable type tag the variable name in a code window. Variable type tags are useful in reading code and preventing bugs. You will not be tempted to assign the statement ‘MyVariable = 57’ if it read ‘strMyVariable = 57’ where the ‘str’ variable tag defines the variable as a string. This method of defining variable types is discussed in the Leszynski/Reddick naming conventions originally published in the August 1993 issue of Smart Access, published by Pinnacle Publishing Inc. (Kent, WA).

It is highly recommended that the Option Explicit statement be added to all decalration section s for all modules, forms, and reports.This forces the developer to correctly declare variable types. Many bugs have been avoided by setting this option.

Using the Variable Type Tag Builder

•	While in a code window, select the Dim statements that you want to apply the varable type tag to.

•	Press the Builder button on the Module Menu bar or from the quick menu on a right mouse click.

•	Select Variable Type Tag Code from the list of code builders. The variable name will be replaced throughout the module with a name that has the type tag prefix.

Tips & Tricks

•	The Builder will will also work in the Declarations section of a module. The variable name will be updated throughout the module.

•	Variable type suffixes (e.g. $,%,#) will be replaced with the correct tag.

Setting the Varable Type Tag

•	Open the AccessPRO Building Tools Options form.

•	Select the Variable Tags tab to set the control colors.


Variable Type Tag Example

Here is a section of code before Varaiable Type Tag builder was applied.

Dim Criteria As String, MyDB As Database, MySet As Recordset

  Dim NewTitle As String

  Criteria = "Title = 'Sales Representative'" '

  NewTitle = "Account Executive"

  Set MyDB = DBEngine.Workspaces(0).Databases(0)

  Set MySet = MyDB.OpenRecordset("Employees", DB_OPEN_DYNASET)   ' Create dynaset.

  MySet.FindFirst Criteria        ' Find first occurrence.

  Do Until MySet.NoMatch          ' Loop until no matching records.

    MySet.Edit                    ' Enable editing.

    MySet!Title = NewTitle        ' Change title.

    MySet.Update                  ' Save changes.

    MySet.FindNext Criteria       ' Find next occurrence.

  Loop                            ' End of loop.

Here is the code after the Varaiable Type Tag builder was applied.

Dim strCriteria As String, dbMyDB As Database, recMySet As Recordset

  Dim strNewTitle As String

  strCriteria = "Title = 'Sales Representative'" '

  strNewTitle = "Account Executive"

  Set dbMyDB = DBEngine.Workspaces(0).Databases(0)

  Set recMySet = dbMyDB.OpenRecordset("Employees", DB_OPEN_DYNASET)   ' Create dynaset.

  recMySet.FindFirst strCriteria        ' Find first occurrence.

  Do Until recMySet.NoMatch             ' Loop until no matching records.

    recMySet.Edit                       ' Enable editing.

    recMySet!Title = strNewTitle        ' Change title.

    recMySet.Update                     ' Save changes.

    recMySet.FindNext strCriteria       ' Find next occurrence.

  Loop                                  ' End of loop.

Without a minimal amount of effort a consistent naming style was applied.


Variable Tag See Also
See Also:

Opening the options form

The Leszynski/Reddick Guidelines for Access 1.x, 2.x

Tags for Access Basic Variables

Beautify Code

Comment Code

Un-Comment Code


Installation Problems
Answer:

Make sure you have the entry:

[Libraries]

wzlib.mda=rw

in your MSACC20.INI file, restart Access and try to install it again.


Answer:

Comment out or remove the standard Access builder entries in the [Property Wizards] section.


The Leszynski/Reddick Guidelines for Access 1.x, 2.x

See Also	Goto Topic

Stan Leszynski and Greg Reddick

Revised: May 25, 1994

The authors wish to thank the individuals who submitted comments on and participated in reviews of the standard.

Stan Leszynski is president of Kwery Corp., which produces several Microsoft® Access® add-on products, including Access To Word and Kwery Control Paks. Stan also manages Leszynski Company, Inc., a consulting group active in database development, which he founded in 1982. He writes and speaks on Access regularly. Stan can be reached at (206) 644-7826 or on CompuServe® at 71151,1114.

Greg Reddick is the president of Gregory Reddick & Associates, a software consulting company specializing in developing solutions in Microsoft Windows® using C/C++, Access, and Visual Basic®. He worked for four years on the Access development team at Microsoft, and has co-authored two Access books. Greg can be reached at (206) 881-6879 or on CompuServe at 71501,2564.

If you've ever inherited a project from another developer, you know how frustrating it is to try to dissect another developer's style and maintain his or her code. When developers code with a common style, however, you can minimize these frustrations. To best share ideas and knowledge, the Access development community will benefit greatly if it adopts a common programming style so that we can benefit from each other's expertise with a minimum of translation overhead. Although Microsoft uses certain naming conventions in the Microsoft® Access® documentation, to date they haven't published an official or comprehensive standard. Thus, we've formulated a set of naming conventions to better serve Access users and developers.

These conventions were originally published in the Charter Issue of Smart Access. Since then, we've logged thousands of hours of development time and scores of comments from Smart Access readers and other users of the conventions, and we continue to improve the style and make it more useful.

Our naming style ties Access conventions closely to Visual Basic® conventions because we recognize that many Access developers also use or plan to use Visual Basic for some data access applications. Access and Visual Basic are becoming more similar with each released version. We've written these naming conventions so you can also use them with Visual Basic database applications.

There are two levels to the naming style. Level 1 is comprehensive, but doesn't clarify objects as explicitly as Level 2. Level 1 is suitable for beginning developers, while Level 2 is intended for more experienced developers and developers involved in complex development projects and multiple-developer environments. You should experiment and choose the level that works best for you. (Please note that not all parts of the standard have two levels.)

If you're already using any previous version of our conventions, you may need to make a few changes to accommodate the enhancements in this revision. Because Access provides little help in renaming objects, you may wish to leave existing applications as is and apply the revised conventions to new projects, going back to existing applications as time permits.

Naming Conventions: An Overview

Our naming style is based on a method of naming called Hungarian, referring to the nationality of its creator, Charles Simonyi (who, incidentally, worked on the first version of Access). Hungarian was first proposed in his doctoral thesis.

Some elements of Hungarian style are used in Microsoft's Visual Basic manuals and Development Kit documentation, among others. Microsoft uses Hungarian internally, and many programmers around the world use it as well. We've adapted the Hungarian style for the Access environment.

In our Access naming style, an object name is made up of four parts: one or more prefixes,  a tag, a base name, and a qualifier. The four parts are assembled as follows:

[prefixes]tag[Basename][Qualifier]

Note   The brackets denote that these components are optional and aren't part of the name.

The tag is the only required component, but in almost all cases the name will have the base name component because you need to be able to distinguish two objects of the same type1. Here are a few examples:

Name	Prefix	Tag	Base	Qualifier
tblCustomer		tbl	Customer
aintPartNum	a	int	PartNum
strCustNamePrev		str	CustName	Prev

Prefixes and tags are always lowercase so your eye goes past them to the first uppercase letter where the base name begins. This makes the names more readable. The base and qualifier components begin with an uppercase letter.

The base name succinctly describes the object, not its class. This is the name you'd likely give the object if you weren't using any particular naming style. For example, in the query name qryPartNum, "PartNum" is the base name; it's an abbreviation for Part Number. Object tags are short and mnemonic. Object prefixes precede some object names and tags and provide further information. For example, if an integer variable intPartNum is an array of part numbers, the prefix "a" for array is added to the front, as in aintPartNum(). Further, a variable that provides an index into the array would use the name of the array prefixed with the index prefix "i", for example, iaintPartNum.

Applying a naming style like this requires more effort up front, but try to imagine which of these two code samples will make more sense to you a year from now when you attempt to modify or reuse your code:

  Z = Y(X)

or

intPart = aintPartNum(iaintPartNum)

Object qualifiers may follow a name and further clarify names that are similar. Continuing with our parts index example, if you kept two indexes to the array, one for the first item and one for the last, the variable iaintPartNum above would become two qualified variables—iaintPartNumFirst and iaintPartNumLast.

Naming Database Objects

Database objects (tables, queries, forms, reports, macros, and modules) are the most frequently referenced items in an Access application. They appear in your macro code, in your Access Basic routines, and in properties. Thus, it's important that you standardize how you name them.

Microsoft's examples in the Northwind Database and Access manuals allow for spaces in object names, but we don't use them in our style. In most database engines and programming languages, including Access Basic, a space is a delimiter character between items, it isn't a logical part of an item's name. Also, spaces in field names don't work in most other database platforms or Windows-based applications such as SQL Server or Word for Windows. Instead, use upper and lowercase designations in names, such as tblAccountsPayable. If spacing is still necessary, use the underscore (_) character instead of a space to be consistent with traditionally accepted SQL syntax and with Access 2.x function naming conventions.

Tags for Database Container Objects

All database container object names in our style have tags. Adding tags to these objects may make them less readable to nondevelopers, but new users will understand their value when they're trying to discern a table from a query in the listbox for a New Report wizard or a form's Control Source property. This is because Access merges table and query names into one long list. Here are Level 1 database container object name tags:

Object	Tag	Example
Table	tbl	tblCustomer
Query	qry	qryOverAchiever
Form	frm	frmCustomer
Report	rpt	rptInsuranceValue
Macro	mcr	mcrUpdateInventory
Module2	bas	basBilling

At Level 1, the only name qualifier (appended to the name) that we use for database container objects is Sub, which we place at the end of a form or report name for a subform or subreport. The form frmProductSupplier would have the related subform frmProductSupplierSub. This allows objects and their subform or subreport to sort next to each other in the database container.

Level 2 tags, shown here, provide more descriptive information.

Object	Tag	Example
Table	tbl	tblCustomer
Table (lookup)3	tlkp	tlkpShipper
Query (select)	qry (or qsel)	qryOverAchiever
Query (append)	qapp	qappNewProduct
Query (crosstab)	qxtb	qxtbRegionSales
Query (data definition)	qddl	qddlAddWorkColumn
Query (delete)	qdel	qdelOldAccount
Query (form filter)	qflt	qfltSalesToday
Query (lookup)3	qlkp	qlkpStatus
Query (make table)	qmak	qmakShipTo
Query (pass-through)	qspt	qsptArchiveQuantity
Query (union)	quni	quniOrderDetail
Query (update)	qupd	qupdDiscount
Form	frm	frmCustomer
Form (dialog)	fdlg	fdlgLogin
Form (menu)	fmnu	fmnuUtility
Form (message)	fmsg	fmsgWait
Form (subform)4	fsub	fsubOrder
Report	rpt	rptInsuranceValue
Report (subreport)4	rsub	rsubOrder
Macro	mcr	mcrUpdateInventory
Macro (for form)5	m[formname]	mfrmCustomer
Macro (menu)6	mmnu	mmnuEntryFormFile
Macro (for report)5	m[rptname]	mrptInsuranceValue
Module2	bas	basBilling
Using our Level 2 style causes objects with similar functions to sort together in the database container in large applications. Imagine that you have a database container with 100 forms in it (we do!), 30 of which are messages that display during the application. Your users now want all message forms to have red text instead of black, so you must change each of the 30 forms. Having the message forms sort together in the database container (because they've all got the same tag) saves you significant effort trying to discern which forms you need to change.

Choose your table names carefully. Since changes to the names of Access objects do not propagate through the database, it is important to name things correctly when the object is created. For example, changing the name of a table late in the development cycle requires changing all the queries, forms, reports, macros, and modules that refer to that table.

You may want to name each database object that refers to a table with the same base name as the table, using the appropriate tag to differentiate them. For example, if your table is tblCustomer, its primary form would be frmCustomer, its primary report would be rptCustomer, and the macros that drive all of the events would be mfrmCustomer and mrptCustomer. We also suggest that you not make table names plural (for example, use tblCustomer, not tblCustomers), because a table usually holds more than one record, so it's plural by implication.

Database Object Prefixes

We use four database object prefixes:

•	"zz" denotes objects you've deserted but may want to keep in the database for awhile for future reference or use (for example, zzfrmPhoneList). "zz" causes the object name to sort to the bottom of the database container, where it's available but out of the way.

•	"zt" denotes temporary objects (for example, ztqryTest).

•	"zs" denotes system objects7 (for example, zstblObjects).

•	"_" denotes objects under development (for example, _mcrNewEmployee). An underscore before an object name sorts to the top of the database container to visually remind you that it needs attention. Remove the underscore when the object is ready to use and it will sort normally.

Tags for Fields

Using tags in field names is a hotly debated issue, even between the authors of this article. Greg maintains that tags in field names uniformly apply the naming style across all database elements and further document your work in Access Basic routines and form or report properties. Stan prefers that the database schema remain pure (platform- and data type-independent) for migration and connectivity to other products or platforms. He prefers that a field name remain independent of its data type.

Consider both positions, along with your unique needs, when you choose whether to apply the field name tags shown here:

Field Type	Tag	Example
Binary8	bin	binInternal
Byte	byt	bytFloorNum
Counter9	lng	lngPKCnt
Currency	cur	curSalary
Date/Time	dtm	dtmHireDate
Double	dbl	dblMass
Integer	int10	intUnit
Long	lng11	lngPopulation
Memo	mem	memComments
Ole	ole	oleEmpPhoto
Single	sng12	sngScore
Text	str13	strFirstName
Yes/No	ysn14	ysnDiscounted
Tags for Control Objects

Access forms and reports automatically assign the field name to the Control Name property when you create a new bound control. Having the control name and field name the same creates some ambiguity in the database schema and in some cases may cause errors in Access Basic code referencing both a control and a field with the same name. To resolve this situation, apply the naming style to form and report controls by inserting the appropriate tag from the list below, in front of the control name suggested by Access. For example, the control name for a field whose Control Source is LastName would be txtLastName.

At Level 1, we recognize that users need to know the difference between an active control and a label, but may not be concerned with the type of the control. Thus the control tags are as follows:

Object	Tag	Example
Label	lbl	lblLastName
Other types	ctl	ctlLastName
Level 1 tags provide the minimum differentiation necessary to still prove useful in functions, macros, and program documentation. For example, the control tags above allow you to differentiate between labels, which aren't modifiable at runtime, and other controls, which accept values from code and users.

Level 2 control tags denote the specific type of the control on the form or report (see table below). This makes Access Basic code and macros more explicit with respect to the properties and events of the individual control.

Object	Tag	Example
Chart (graph)	cht	chtSales
Check box	chk	chkReadOnly
Combo box	cbo	cboIndustry
Command button	cmd	cmdCancel
Frame (object)	fra	fraPhoto
Label	lbl	lblHelpMessage
Line	lin	linVertical
List box	lst	lstPolicyCode
Option button	opt	optFrench
Option group	grp	grpLanguage
Page break	brk	brkPage1
Rectangle (shape)15	shp	shpNamePanel
Subform/report	sub	subContact
Text box	txt	txtLoginName
Toggle button	tgl	tglForm
The only prefix for controls, "zs", appears at Level 2. It denotes system-level controls used by the form or code but not displayed to the user. Such controls usually aren't visible at run time but they may store temporary values or parameters passed to the form.

Naming Access Basic and Macro Objects

Using standardized and descriptive variable, constant, and function names greatly enhances the ability of developers to share, maintain, and jointly develop code.

Procedures and Macros

Access Basic requires that each nonprivate procedure name in a database be unique. For a function called from a property on a form in Access 1.x, construct the function name as follows:

formname_controlname_propertyname16

For example:

frmEmployee_cmdAdd_Push

This tells you that this function is called from the OnPush property of the control cmdAdd on the form frmEmployee. For a property that affects the entire form, just use formname_propertyname, as in frmEmployee_Open. If two or more controls on one form execute the same code, create unique functions for each using the naming style in this section, then have each of these functions call the same private function that contains the common code.

In Access 2.x, the code for controls on a form is stored attached to the form, so the form name is implied in the function and does not need to be in the function name. Thus, the example above becomes:

cmdAdd_Click17

Macro names inside a macro group also use this format. In the macro group mfrmEmployee, the macro txtName_BeforeUpdate contains the actions for the txtName control's BeforeUpdate event. For example, the txtName control on your frmEmployee form would have one of these properties, depending on whether you use modules (Access 1.x), attached code (Access 2.x), or macros to implement the task:

1.x code:	BeforeUpdate....	=frmEmployee_txtName_BeforeUpdate()

2.x code:	BeforeUpdate....	=txtName_BeforeUpdate()

Macros:	BeforeUpdate...	mfrmEmployee.txtName_BeforeUpdate

You should prefix procedure names in library databases with a unique set of characters to prevent their names from conflicting with any other names from attached libraries. The prefix should be in uppercase letters, followed by an underscore, and be no more than four letters. For example, we prefix all the library function names for our mail-merge utility, Access To Word, with "ATW_". Global constants and variables in a library should use the same prefix because they must also be unique across the entire database name space. Similarly, it is important to use these prefixes in Declare statements to alias all external dynamic-link library (DLL) function and procedure calls.

Tags for Access Basic Variables

Every Access Basic variable should have a type tag from the following list:

Variable Type	Tag	Example
Container	con	Dim conTables as Container
Control	ctl	Dim ctlVapor As Control
Currency	cur	Dim curSalary As Currency
Database	db	Dim dbCurrent As Database
Document	doc	Dim docRelationships as Document
Double	dbl	Dim dblPi As Double
Dynaset	dyn	Dim dynTransact As Dynaset
Flag (Y/N, T/F)18	f	Dim fAbort As Integer
Field	fld	Dim fldLastName as Field
Form	frm	Dim frmGetUser As Form
Group	gru	Dim gruManagers as Group
Index	idx	Dim idxOrderId as Index
Integer	int	Dim intRetValue As Integer
Long	lng	Dim lngParam As Long
Object	obj	Dim objGraph As Object
Parameter	prm	Dim prmBeginDate as Parameter
Property	prp	Dim prpUserDefined as Property
QueryDef	qdf (or qrd)	Dim qdfPrice As QueryDef
Recordset	rec (or rst)	Dim recPeople as Recordset
Relation	rel	Dim relOrderItems as Relation
Report	rpt	Dim rptYTDSales As Report
Single	sng	Dim sngLoadFactor As Single
Snapshot	snp	Dim snpParts As Snapshot
String	str	Dim strUserName As String
Table	tbl	Dim tblVendor As Table
TableDef	tdf (or tbd)	Dim tdfBooking as TableDef
Type (user-defined)	typ	Dim typPartRecord As mtPART_RECORD
User	usr	Dim usrJoe as User
Variant	var	Dim varInput As Variant
Workspace	wrk (or wsp)	Dim wrkPrimary as Workspace
Yes/No18	ysn	Dim ysnPaid As Integer
Our style doesn't use data-type suffixes such as $ and % on variable names, because the Access and Visual Basic documentation recommends against using these suffixes.

Tags for database object variables such as the Form and Report types are the same as those used for the objects. This helps when coding, because the variable you assign an object to (for example, tblVendor) usually has the same name as the object it references (tblVendor), providing you with consistent object names when coding.

Constants and User-Defined Types

It is common practice in programming for Windows to use uppercase names for constants, but the authors differ on how to treat constants. Stan prefers using the uppercase notation and adding a scope prefix (see below), so a global constant for a specific error might be gNO_TABLE_ERROR. Greg prefers to treat constants as typed variables without scope, for example, strNoTableError.

In the above table, we've added a variable type tag of "typ" for user-defined types, and suggest a convention that matches that of constants, because you can think of both user-defined types and user-defined constants as persistent, user-created objects. The recommendations for a user-defined data type syntax include the following:

•	Use uppercase letters (or upper/lower syntax if you use that optional convention for globals).

•	Use a tag of "t" in front of the type name to denote that it's a type structure.

•	Use "g" and "m" prefixes to denote the scope of the type (see below).

Prefixes for Scope

Level 2 of the naming convention introduces scope prefixes for variables and constants. The scope prefix comes before any other prefixes.

•	Variables declared locally with a Dim statement have no prefix.

•	Variables declared locally with a Static statement are prefixed with an "s", as in "sintAccumulate".

•	Variables that are declared in the Declarations section of a module (or form in Visual Basic) using a Dim statement are prefixed with an "m", as in "mcurRunningSum".

•	Variables declared with global scope using a Global statement in the Declarations section have the prefix "g", as in "glngGrandTotal".

•	Variables that denote parameters passed to a function (in the parentheses after the function name) have a prefix of "p", as in "pstrLastName". Alternately, we sometimes use "r" instead of "p" for values passed to a function by reference, and "v" for values passed ByVal, when both types of parameters are used in a single function declaration.

Object qualifiers follow the variable name and further differentiate it from similar names. You'll probably devise a list of qualifiers relevant to the types of applications you develop, but here are some of our common ones:

Variable Property	Qualifier	Example
Current element of set	Cur	iaintCur
First element of set	First	iaintStockFirst
Last element of set	Last	iaintStockLast
Next element of set	Next	strCustomerNext
Previous element of set	Prev	strCustomerPrev
Lower limit of range	Min	iastrNameMin
Upper limit of range	Max	iastrNameMax
Source	Src	lngBufferSrc
Destination	Dest	lngBufferDest
Access Basic Labels

For Access Basic labels, we use a qualifier on the function name to create several standard labels. For On Error GoTo statements, we use the name of the function with the qualifier _Err appended, for example:

cmdAdd_Click_Err:

Some functions also have a label for jumping forward to the end of the function, because it's more appropriate to leave a function only in one place than to scatter Exit Function statements throughout a routine. We use the Done qualifier, as in:

cmdAdd_Click_Done:

Access Basic Example

Below is an example of an Access Basic routine using the naming conventions. Note these items:

•	We put a header in every function that describes, at a minimum, purpose, comments, author's name/date, last revision date and notes, and parameters passed and/or returned.

•	We return to the Done routine from the Error routine to ensure that open objects are closed properly before exiting the function. The temptation to simply use Exit Function from an error handler may leave files open and locked.

•	The example was originally written for Access 1.x and uses syntax that has been modified in 2.x (for example, CreateDynaset is now OpenRecordset).

Function EliminateNulls (ByVal vstrFieldName As String, ByVal vstrTableName As String) As Integer

' What:       Replaces Null values with unique ascending integers

'             A standardized version of a routine from NWIND and Chapter 8

' Author:     Microsoft  Created: 11/92  Last Revision: 5/25/94  By: grr/swl

' Passed in:  field name and table name

' Returns:        0/-1

    On Error GoTo EliminateNulls_Err

    Dim db As Database

    Dim dynTableSrc As Dynaset

    Dim varCounter As Variant

    Dim varCriteria As Variant

    EliminateNulls = 0

    Set db = CurrentDB()

    Set dynTableSrc = db.CreateDynaset(vstrTableName)

    varCounter = DMax(vstrFieldName, vstrTableName)

    If IsNull(varCounter) Or IsEmpty(varCounter) Then

        varCounter = 1

    Else

        varCounter = Val(varCounter) + 1

    End If

    varCriteria = vstrFieldName & " = Null"

' Iterate over all records in the table, throw out records with Nulls

    dynTableSrc.FindFirst varCriteria

    Do Until dynTableSrc.NoMatch

        dynTableSrc.Edit

        dynTableSrc(vstrFieldName) = varCounter

        dynTableSrc.Update

        varCounter = varCounter + 1

        dynTableSrc.FindNext varCriteria

    Loop

    EliminateNulls = -1

EliminateNulls_Done:     ' Jump here to clean up and exit

    dynTableSrc.Close

    db.Close

    On Error GoTo 0

Exit Function

EliminateNulls_Err:

    Select Case Err

        ' Handle specific errors here

    Case Else

        ' Generic error handler here

    Resume EliminateNulls_Done

    End Select

End Function

Putting Standards into Practice

Naming conventions never replace the judicious use of comments in your table definitions, macro code, or Access Basic routines. Naming conventions are an extension of, not a replacement for, good program-commenting techniques.

Formulating, learning, and applying a consistent naming style requires a significant initial investment of time and energy. However, you'll be amply rewarded when you return to your application a year later to do maintenance or when you share your code with others. Once you implement standardized names, you'll quickly grow to appreciate the initial effort you made.

If the entire Access community, including Microsoft, coded using  one common naming style, we'd all find it easier to share information about Access. With this in mind, we submit these revised guidelines to the Access community.

This document accompanied the August 1994 issue of \i0 Smart Access Journal, published by Pinnacle Publishing, Inc. Earlier versions of these guidelines were published in the February and August 1993 issues of \i0 Smart Access.

This document copyright 1993-1994 by Stan Leszynski and Greg Reddick. It may be distributed freely as long as no profit is made from its publication or distribution, or from publications that include it, and the complete text is published or distributed without alteration of the content. All other rights reserved. Please send the authors a copy of any publication that includes this document.

1	Having the tag as the only required part may seem counterintuitive, but in Access Basic you can have code that deals with a generic form passed as a parameter. In this case you'd use "frm" as the parameter name; the base name isn't required except to distinguish it from a different form object variable in the code.

2	The module tag 'bas' is used to maintain consistency with the filename extension used by Visual Basic modules.

3	A look-up table or query has information used only to populate combo and list boxes on forms , validate certain fields in another table, or join with short codes or keys to pull descriptive text into reports.

4	Level 2 recognizes that an advanced user may place a single subform/subreport in several different objects, thus the Level 1 technique of naming the sub-object with the same base name doesn't work.

5	We prefer to create one macro group for each form and report in the system, so the naming convention adds an "m" to the front of the form or report name to create a hybrid macro name tag.

6	We suggest you use the menu bar name (File, Edit, Help, and the like) as a qualifier at the end of menu macro names.

7	System objects are items that are part of the development and maintenance of an application not used by end-users, such as error logs, development notes, documentation routines, relationship information, and so on. Note that "zs" is a prefix. It causes the system objects to sort toward the bottom of the database container.

8	The Access engine ("Jet") supports a data type called binary but the Access user interface doesn't expose it to the user. It's still possible to get a field with the binary data type by importing or attaching certain external tables. Also, some of the system table fields use this data type.

9	Internally, Access treats a counter data type as a long integer with a special property called auto-increment. Because counter fields are often referenced by foreign keys and the data type in the other table is a long, Greg uses the same tag as a long. Optionally, if you want to distinguish a counter from a long, use the qualifier Cnt at the end of the name.

10	C programmers may prefer "w".

11	C programmers may prefer "dw".

12	Some users find "sgl" more mnemonic.

13	The tag "str" is used as opposed to "txt" because a textbox control uses "txt". C programmers may prefer "sz".

14	C programmers may prefer "f".

15	Our style recognizes that Visual Basic uses the term "shape".

16	Access has a 40 character length limit for function and label names.  When using this style, we suggest that you use short form and control names (less than 20 characters) to avoid exceeding the limitation.

17	Access 2.x renamed the Push event to Click.

18	Use "ysn" for a variable that stores the value of a field of data type Yes/No; use "f" to denote a flag variable used to control program flow. "f" is widely used by C and BASIC programmers for true/false variables.


NameBuilder See Alse
See Also:

The Leszynski/Reddick Guidelines for Access 1.x, 2.x

Tags for Control Objects

Opening the options form

Color Builder

StatusBarText, InputMask, and Format Builders


Control Nudgers See Also
See Also

NameBuilder

Color Builder

StatusBarText, InputMask, and Format Builders


The LR See Also
See Also

NameBuilder

Variable Type Tag


Ordering Information

AccessPRO Building Tools may be ordered in the the following ways:

Ordering by check or money order

Order by credit card

Purchase Orders

A single license is $65 CAN. AccessPRO Building Tools is shipped on 3.5 inch diskettes only.

Mailing Address:

Mississauga Software Technologies

6040 Montevideo Road, Unit 19

Mississauga, Ontario, Canada

L5N 2T4

E-Mail Address:

MissSoftTech@msn.com

Sales phone number:

(905) 858-4608

Fax Number:

(905) 858-0984


Goto Topic:

Naming Conventions: An Overview

Naming Database Objects

Tags for Database Container Objects

Database Object Prefixes

Tags for Fields

Tags for Control Objects

Naming Access Basic and Macro Objects

Tags for Access Basic Variables

Constants and User-Defined Types

Prefixes for Scope

Access Basic Labels

Access Basic Example

Putting Standards into Practice


Order by Check or Money Order

Send the completed order form along with the check or money order by mail to:

Mississauga Software Technologies

6040 Montevideo Road, Unit 19

Mississauga, Ontario, Canada

L5N 2T4


Order by Credit Card

Call Mississauga Software Technologies sales desk between the hours of 9:00 AM to 5:00 PM, Monday to Friday Eastern Time at:

(905) 858-4608

or send the completed order form by mail to:

Mississauga Software Technologies

6040 Montevideo Road, Unit 19

Mississauga, Ontario, Canada

L5N 2T4

or send the completed order form by e-mail to:

MissSoftTech@msn.com

or fax the completed order form to:

(905) 858-0984


Purchase Orders

Purchase orders (net 30 days) are accepted only from government and accredited educational institutions and major corporations, provided that they are submitted on purchase order forms with a purchase order number. Send the completed order form with a purchase order to:

Mississauga Software Technologies

6040 Montevideo Road, Unit 19

Mississauga, Ontario, Canada

L5N 2T4

or fax the completed order form with the purchase order to:

(905) 858-0984


Order Form

Order Form For AccessPRO Building Tools Version 1.2

      ___ copies at $65.00 CAN    per license: ______________

           Ontario residents add 8% sales tax: ______________

                  Shipping and handling $5.00: ______________

                                Total payment: ______________

Payment By:

Check( ) Money Order( ) Purchase Order( )

   MasterCard( ) VISA( ) AMEX( )

   Credit Card Number: ____-____-____-____

      Expiration Date: __/__

         Name On Card: _____________________________________

Ship To:

     Name: ________________________________ Date:___________

  Company: _________________________________________________

  Address: _________________________________________________

     City: _________________________________________________

  Country: _________________________________________________

Day Phone: ___________________ Evening: ____________________

Electronic Mail address: ___________________________________

How did you hear about AccessPRO Building Tools?

____________________________________________________________

Comments:

___________________________________________________________________

Bill To:

Same as above( )

     Name: _________________________________________________

  Company: _________________________________________________

  Address: _________________________________________________

     City: _________________________________________________

  Country: _________________________________________________

Day Phone: ___________________ Evening: ____________________

Electronic Mail address: ___________________________________

Fax: (905) 858-0984	Mail: 	Mississauga Software Technologies

Sales: (905) 858-4608	6040 Montevideo Road, Unit 19

Mississauga, Ontario, Canada

L5N 2T4


License and Warranty

You should carefully read the following terms and conditions before using this software. Use of this software you indicates your acceptance of this license agreement and warranty.

Registered Version

One registered copy of AccessPRO Building Tools may either be used by a single person who uses the software personally on one or more computers, or installed on a single workstation used nonsimultaneously by multiple people, but not both.

You may access the registered version of AccessPRO Building Tools through a network, provided that you have obtained individual licenses for the software covering all workstations that will use the software through the network.  For instance, if 5 different workstations will use AccessPRO Building Tools on the network, each workstation must have its own AccessPRO Building Tools  license, regardless of whether they use AccessPRO Building Tools at different times or concurrently.

Disclaimer of Warranty

THIS SOFTWARE AND THE ACCOMPANYING FILES ARE SOLD "AS IS" AND WITHOUT WARRANTIES AS TO PERFORMANCE OF MERCHANTABILITY OR ANY OTHER WARRANTIES WHETHER EXPRESSED OR IMPLIED. Because of the various hardware and software environments into which AccessPRO Building Tools may be put, NO WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE IS OFFERED.

Good data processing procedure dictates that any program be thoroughly tested with non-critical data before relying on it. The user must assume the entire risk of using the program. ANY LIABILITY OF THE SELLER WILL BE LIMITED EXCLUSIVELY TO PRODUCT REPLACEMENT OR REFUND OF PURCHASE PRICE.

Shareware Version Evaluation and Registration

This is not free software. You are hereby licensed to use this software for evaluation purposes without charge for 50 uses. See Ordering Information for details on purchasing the product. When payment is received you will be sent a registered copy of the latest version of AccessPRO Building Tools.

Distribution

Provided that you verify that you are distributing the Shareware Version (select About Tab from the Building Tools Option Form to check) you are hereby licensed to make as many copies of the Shareware version of this software and documentation as you wish; give exact copies of the original Shareware version to anyone; and distribute theShareware version of the software and documentation in its unmodified form via electronic means.  There is no charge for any of the above.

You are specifically prohibited from charging, or requesting donations, for any such copies, however made; and from distributing the software and/or documentation with other products (commercial or otherwise) without prior written permission from Mississauga Software Technologies.


Registered Version
Answer:

The registered version includes unlimited use of the product as stated in the license agreement. Also, the registered version is the latest copy that includes more builders, code snippets and other goodies !!.Plus, you will be helping support the continued development of other fine products from Mississauga Software Technologies.