Bob Hall
rjhjr at cox.net
Sun Aug 3 22:52:04 CDT 2003
On Mon, Aug 04, 2003 at 12:02:54PM +1000, Darren DICK wrote: > Hello all > I want to separate my 'favourite's code bits and pieces into a separate db (MDA?) then > have any new dB 'reference' the MDA. > > 1 How do I go about this? You can do this with an mdb file, but mdas and mdes will work also. Put the file anyplace where you can find it from your project mdb's browser. In the VBA IDE, select the References item from the Tool menu. Browse for your library, and double click it. After that, the public procedures in any standard modules in your library will be available in your project mdb. > 2 What are the 'gotchas' etc? If your mdb is going to be used by anyone other than you, then it's not worth it, for two reasons: 1) If you have code in two files instead of one, then you've got two files to keep track of, instead of one. You'll be amazed how many times you'll forget to include the library file with the main file. I'm sometimes forced to divide code between two different files, but I avoid it when possible. 2) Access sets four references for VBA, by default. Additional references tend to break. To make your code reliable, you have to put code in a start-up form that checks the references and repairs any broken references. If you don't do this, you are going to have to fix the references for your users whenever they break. I have a library of string-parsing routines that I like to keep handy for various tasks. For example, I've got a routine that finds the first occurence of a substring after the Nth occurence of another substring. I always import any routine I use into the mdb that uses it. The hassle associated with add-ins isn't worth it. Bob Hall