[AccessD] Getting into libraries

Dan Waters df.waters at comcast.net
Wed Feb 27 10:56:58 CST 2013


Hi John,

I've use a library for several years.  Each of my systems at my customers
uses it as the 'base' for the app.  It has about 80 objects and 25K lines of
code.  

Some thoughts:

1)  My Library is an mdb.  I've never tried to use an mda.  I just add the
PSILibrary.mdb file to the references in the Main app file.

2)  You can any object into a library.  Putting commonly used forms and
reports into a library is very efficient for a developer.  You do it like
this:

In the library, put this into a module:

    Public Sub OpenLibraryForm(stgFormName As String, _
                               Optional acFormView As Variant = acNormal, _
                               Optional varFilterName As Variant = "", _
                               Optional varWhereCondition As Variant = "", _
                               Optional acFormOpenDataMode As Variant =
acFormPropertySettings, _
                               Optional acWindowMode As Variant =
acWindowNormal, _
                               Optional varOpenArgs As Variant = "")

        DoCmd.OpenForm stgFormName, acFormView, varFilterName, _
            varWhereCondition, acFormOpenDataMode, acWindowMode, varOpenArgs

    End Sub

Now from the main app you can call this procedure like:

    Call OpenLibraryForm("frmFormInLibrary")

And, you can add in any of the form's opening parameters that you like.

Opening a report works the same way.

3)  While code is running in the Library, you can call a procedure in the
Main app like this:

	Application.Run("ProcedureName","1stParameter", "2ndParameter") and
so on.

You need to test this carefully because the procedure name and the parameter
types are not checked while compiling.

4)  You need to be aware of the difference between CurrentDB and CodeDB.

For example, if you do this in the Library:

	Set rst = CurrentDb.OpenRecordset("qryName", dbopensnapshot)

And "qryName" exists in the Library but not in the Main app, this will error
out because CurrentDB looks for the query in the Main app, but not in the
Library.   If you do this:

	Set rst = CodeDb.OpenRecordset("qryName",dbOpenSnapshot)

And if "qryName" is in the Library, then this will work.

Good Luck!
Dan

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of John W Colby
Sent: Tuesday, February 26, 2013 9:42 PM
To: Access Developers discussion and problem solving
Subject: [AccessD] Getting into libraries

I have decided to take a short detour into how to use a library. While it
takes a bit of setting up, it really opens up the horizons.

jwcolby.blogspot.com

--
John W. Colby

Reality is what refuses to go away
when you do not believe in it

--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com



More information about the AccessD mailing list