Microsoft Access VBA Coding Conventions

From database24
Revision as of 15:57, 29 November 2011 by Dec (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

General

In general please refer to the Visual Basic Coding Convenstions.

Architecture

Access database applications should always be split up into a frontend and a backend.

The frontend contains

  • Tables
    • Links to backend tables
    • Temporary tables
  • Queries
  • Forms
  • Reports
  • Macros
  • Code

The backend contains

  • Tables

Multi User Environment

In a multi user environment, the frontend is usually copied to the local hard drive, while the backend resides on a file server.

Temporary frontend tables must be prefixed properly and must be suffixed per user. While it is not recommended to leave the frontend on a file server, there are still scenarios, where concurrent frontend accesses could happen—and in this case the functionality of the database has to be ensured.


Indentation

The indentation size is 4.

Empty lines

Variables

  • Early binding
  • No globals
  • No abbreviations
  • Make use of the variable type prefix

Access Classes

Forms

  • Group
    • Form event procedures
    • From control event procedures
    • Methods

Reports

Function

Name

The function name starts with a verb in lower case.

Result

The result variable is declared as first variable and the result assignment is the last statement in every function.

Conditions

  • If, ElseIf, Else, End If

Loops

  • Do Loop
  • Not: While Wend

Classes