Making a Library (.MDA) file

A library file or database, put very simply, is a collection of objects that can be called from or used by your application. An MS-Access library database is constructed in the same manner that the normal Access database is. The only difference lies in the name - library databases have an extension of MDA whereas normal databases are recognised by the MDB extension.

There are further differences, of course, in the manner they are used. But we will get to that a little later.

Why is a library database useful? Think of all those functions that you write over and over again with a different parameter name maybe? Or a slightly different name? Or something as useful and common as the NullToZero() function? Or something specific that you have developed? You needn't include these functions in ALL your applications. Put them in a library database and ensure that Access knows that your library is to be used. That's it! Then you can call your functions as if they were included in your application database.

The other plus is that you can secure your utilities and distribute them to your clients. So that the ownership of the code rests with you always and the chances of piracy and plagiarism are reduced. (Note, I say reduced and not eliminated entirely!! For as long as Access Basic is an interpreted language, a smart hacker will be able to get to your code, if he wants!)

Once you have decided that you want to build your own library....

1. Put the commonly used objects in a new database.

2. Close this new database and rename it to have an MDA extension.

3. Then locate your msaccess.ini file. This is usually in your Windows directory. Open this using Notepad.

4. Search for the string "Libraries". You might find that this section called Libraries (enclosed in square brackets) already has a few entries under it. These are the wizards that you use ever so often to make all those fancy forms and reports! Yes, they are nothing but library databases, written in MS-Access!!

5. Write the full path of your library database followed by

=rw

This ensures that the next time you open your application database using Access, your library database will also be opened in memory and its objects will be available for use in your application!

(You needn't include the full path to your library database if it is in the Access directory with the other wizards. But it is a good practice to do so...)

 

Back to MS Access Tips

Perfect Paradigm - A Solutions Company