Why use a Naming Convention?
Using a naming convention when creating your Access Database is vital. A good naming convention will help stop errors that can occur due to badly named objects and will make the initial development quicker and easier. The naming convention will also make life easier when revisiting a database to add new functionality, which maybe in a few months or even years time.
The following rules for naming objects in your Access Database should always be observed; these apply to the naming of everything within your database from tables, queries, forms, reports, macros and Vba modules to field names within tables and controls within forms and reports: (not following rules 1 and 2 can cause errors within your database, the other rules are optional but very highly recommended)
1 Do Not Use Spaces Or Special Characters
If you have never done any type of development or programming before you may be tempted to use spaces or special characters when naming database objects; this can make it difficult (or produce errors) when referring to them in queries or Vba. The use of spaces or special characters WILL end up causing you problems always avoid them when naming objects in your database.
Special characters / \ | @ £ ^ ( ) [ ] { } ; : ! # & = * + - ? " ' $ %
2 Do Not Use Reserved Words
Reserved words are words that are reserved for use by built in Access functionality or SQL functionality. The most common reserved words that new developers use when naming database objects are: Date, Day, Month, Year; so for example a developer may have a field in the Sales table called ‘Date’ this should be avoided and should be called something like ‘SaleDate’. Click here for a full list of reserved words.
3 Keep Names Short But Informative
A table or query etc… needs to have a name that is informative but not too long or too short. For example a query named ‘qryListOfSalesForEachDepotGroupedByMonth’ should be called something like ‘qryMonthlySalesByDepot’ and should definitely not be called ‘qryMSD’.
4 Use Title Case
A query named ‘qryMonthlySalesByDepot’ is easier to read than a name written in all low or upper case i.e. ‘QRYMONTHLYSALESBYDEPOT’ or ‘qrymonthlysalesbydepot’
5 Use Name Prefixes
The following are a list of prefixes and example names to use when naming objects. By using a prefix you can easily distinguish between different object types that have the same name. I.e. if you have a table named ‘Staff’ and a report named ‘Staff’ it is difficult to tell which is which, so name them ‘tblStaff’ and ‘rptStaff’.
Database Objects
| Object Type |
Prefix |
Example Object Name |
| Tables |
tbl |
tblSalesDetails |
| Queries |
qry |
qryMonthlySales |
| Forms |
frm |
frmSalesDetails |
| Reports |
rpt |
rptMonthlySales |
| Macro |
mcr |
mcrDeleteSales |
| Modules |
mod |
modSalesFunctions |
Form/Report Objects
| Object Type |
Prefix |
Example Object Name |
| Combo Box |
cmb |
cmbStaff |
| List Box |
lst |
lstStaff |
| Button |
cmd |
cmdClose |
| Text Box |
txt |
txtFirstName |
| Label |
lbl |
lblFirstName |
| Check Box |
chk |
chkCurrent |
| Option Group |
grp |
grpReportStyle |
| Subform/Report |
sub |
subMonthlySales |
| Toggle Button |
tgl |
tglShowPhoto |
| Image |
img |
imgStaffPhoto |
| Tab Control |
tab |
tabSales |
|