Databases - MS Access Modules

In MS Access, all code is stored in "Modules". Most of these Modules are associated with Forms and Reports. However, it is also possible to store code as just a Module. (This is one of the tabs in the "Database Window".)

In general, Modules are used to make routines re-usable. A collection of re-usable routines is sometimes called a library.

When a module has a combination of Public and Private routines, and contains "Properties" (ie, it contains Property Let, Property Get, and Property Set procedures), then the MS Access help refers to it as an "Object". (Not a particularly accurate definition.)

The only real trick is to remember to change the procedures (functions and subroutines) from Private (the default value) to Public.

I add _lib (Library) to the end of procedure names to indicate that the code is located in a module. This just makes it a little easier for other people to read my code. If you use lots of modules (libraries), then you may want to add additional identifiers to indicate which module it is in.

Linking to Modules in Another mdb File

It is possible to link to modules (libraries) in another mdb file.

Modules I Use

This module treats Forms as Dialog boxes. You simply pass the Dialog Box name and a parameter - it returns a value. The rest depends on what the dialog box does.

Well, I didn't write this one, but I definitely suggest using it. It prints (draws) 3 of 9 barcodes on reports.

String Functions
ExtractData_lib Returns the string between 2 patterns
TrimAll_lib Removes leading tabs and spaces
Replace_lib Replaces all occurances of one string with another
ReplaceFirst_lib Replaces the first occurance of one string with another

Author: Robert Clemenzi -
URL: http:// / user / clemenzi / technical / Databases / MSAccess / Modules.html