[AccessD] Getting into libraries

John W Colby jwcolby at gmail.com
Wed Feb 27 12:37:55 CST 2013


Dan, thanks for all of this.

As I mentioned in the blog, the extension is essentially meaningless, just a way for MS to designate 
what a file is /if/ they created it - they will use their suggested extensions.  So you can 
reference an MDB, MDA or MDE.  I have never tried to reference a valid container with an extension 
other than those (for example .XYZ) but I suspect that it would work.

I have used forms in a library but it was problematic getting the data into the form since I always 
used bound forms.  Unbound forms were easier and I did place (for example) my login form.  I am 
aware that you can place anything in there but actually using them requires a certain expertise.  In 
my blog, for the moment, I am focusing on code libraries.

I do appreciate the info though and it would be great if you would add a comment to that blog post 
with this information so that my readers can think about the implications.

John W. Colby

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

On 2/27/2013 11:56 AM, Dan Waters wrote:
> 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