

The application should handle all internal errors. All Functions and Subs will have their own integral error-handlers.
Modules should be fully documented. Each Procedure or Sub should have a text heading which may include the following information :
|
What : | |
|
Author : | |
|
Passed : | |
|
Created: | |
|
Revision : | |
|
Returns : |
Always declare variables and type. Always have Option Explicit set in the Declarations section. This will prevent a mis-spelt variable being accepted and used by the system. You should explicitly declare all variables, each on a line by itself. Do not use the old type declaration characters, such as %, &, and $. They are extraneous if you use the naming conventions, and there is no character for some of the data types, such as Boolean. You should always explicitly declare all variables of type Variant using the As Variant clause, even though it is the default.
Constants should always have a data type. Constants declared in the General Declarations section of a module should always have a scope keyword of Private or Public, and be prefixed by the scope prefixes m or g, respectively. A constant is indicated by appending the letter c to the end of the data type for the constant. For example: Private Const mdblc_Pi As Double = 3.14159265358979
Scope prefixes :
|
Prefix |
Object Type |
|
(none) |
Local variable, procedure-level lifetime, declared with "Dim" |
|
s |
Local variable, object lifetime, declared with "Static" |
|
m |
Private (module) variable, object lifetime, declared with "Private" |
|
g |
Public (global) variable, object lifetime, declared with "Public" |
Variable prefixes :
|
Tag |
Object Type |
|
bln |
Boolean |
|
byt |
Byte |
|
cur |
Currency |
|
dtm |
Date |
|
dec |
Decimal |
|
dbl |
Double |
|
int |
Integer |
|
lng |
Long |
|
obj |
Object |
|
sng |
Single |
|
str |
String |
|
stf |
String (fixed length) |
|
var |
Variant |
For user-defined procedure names, capitalize the first letter of each word in the name. For example:
|
GetTitleBarString | |
|
PerformInitialisation |
Procedures should always have a scope keyword, Public or Private, when they are declared. For example:
|
Public Function GetTitleBarString() As String | |
|
Private Sub PerformInitialisation |
Parameters in a procedure definition should be prefixed with ByVal or ByRef, even though ByRef is optional and redundant. Procedure parameters are named the same as simple variables of the same type, except that arguments passed by reference use the prefix "r". For example:
|
Public Sub TestValue(ByVal intInput As Integer, ByRef rlngOutput As Long) | |
|
Private Function GetReturnValue(ByVal strKey As String, ByRef rgph As Glyph) As Boolean |
Arrays of an object type use the prefix "a". For example:
|
aint_FontSizes | |
|
astr_Names |
Labels are named using upper and lower case, capitalizing the first letter of each word. For example:
|
ErrorHandler: | |
|
ExitProcedure: |
Object library names must be included, where appropriate, in references, to avoid confusion.
For example :
|
Dim rst As ADODB.Recordset or Dim rst As DAO.Recordset or Dim cat As ADOX.Catalog |
It is preferred that ADO is implemented rather than ADO. This is partly to handle the eventual redundance of DAO, and partly to allow the code to be transportable to other technologies, such as ASP.
However, ADO is only partially implemented into earlier versions of Access, and so in many cases DAO may have to be used to compensate for ADO deficiencies, such as Form RecordsetClones.
DAO object tags :
|
Tag |
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 |
QueryDef |
|
qrys |
QueryDefs |
|
rst |
Recordset |
|
rsts |
Recordsets |
|
rel |
Relation |
|
rels |
Relations |
|
tbl |
TableDef |
|
tbls |
TableDefs |
|
usr |
User |
|
usrs |
Users |
|
wrk |
Workspace |
|
wrks |
Workspaces |
ADO CursorTypes, LockTypes, CursorLocations and Options should always be defined explicitly, rather than omitted to assume a default.
The Developer must appreciate what types of recordsets are actually returned from what recordset requests.