[AccessD] Leave a bound form in a library.

jwcolby jwcolby at colbyconsulting.com
Wed Oct 13 17:15:46 CDT 2010


Yes, this is the method I went with.



John W. Colby
www.ColbyConsulting.com

On 10/13/2010 9:55 AM, A.D. Tejpal wrote:
> J.C.,
>
>      You were interested to know whether a form belonging to library db (not functioning as an AddIn) could be loaded with data from host db, without resorting to a wrapper query using IN clause.
>
>      On further examination, it is observed the needful can be done by taking advantage of the fact that when an external db is serving as a library db, the terms CurrentDb and CurrentProject (whether used in code module of library db or that of host db) point to the host db. On the other hand, CodeDb and CodeProject point to the library db.
>
>      Sample operative statement for loading an open library form with a query from host db would be as follows. This syntax is equally effective, whether placed in code module of library db or that of host db:
> '=====================================
>      Set Forms("LibraryFormName").Recordset = _
>            CurrentDb.OpenRecordset(HostDbQueryName)
> '=====================================
>
>      Note:
>      (a) An attempt to open the library form using DoCmd method directly from host db code, leads to error 2102 (named form does not exist). The form is therefore opened by calling appropriate subroutine located in library db's module, using the library reference as qualifier.
>      (b) An attempt to assign the host db query to RecordSource property of library form leads to error 2580 (Specified record source does not exist)
>      (c) If host db query / table is assigned to library db form via third argument of DoCmd.OpenForm method, it is not effective - although there is no error.
>      (d) When a form in library db is opened in host db, it gets included in forms collection of host db and its controls can be accessed via conventional syntax in host db's code.
>      (e) Any attempt to assign a form belonging to host db as the source object for a subform control located on a library form, meets with failure, attracting a message implying (somewhat misleadingly) that Jet is unable to locate the subform control itself. Apparently, mixing up of objects between library and host db's is not permitted.
>      (f) If the host db has a form with exactly the same name as that of a library form, it can be opened with direct click, even if library form with this name is already open. This is an unusual situations where the Forms collection of host db shows two forms with identical names.
>
>      In this context, my sample db named ExternalDbAsLibraryRef might be of interest. It is in access 2000 file format and is available at Rogers Access Library. Link:
> http://www.rogersaccesslibrary.com/forum/forum_topics.asp?FID=45
>
>      This sample db demonstrates three styles as follows (style (c) might be pertinent to your needs):
>      (a) Open library form loaded with library db data
>      (b) Open host db form loaded with library db data
>      (c) Open library form loaded with host db data
>
> Best wishes,
> A.D. Tejpal
> ------------
>
>    ----- Original Message -----
>    From: jwcolby
>    To: Access Developers discussion and problem solving
>    Sent: Wednesday, September 01, 2010 21:44
>    Subject: Re: [AccessD] Leave a bound form in a library.
>
>
>    A.D.
>
>    Thanks for that. I am working on a Presentation Level Security System (PLSS) AKA my Lightweight Security System.  The PLSS is not an add-in in the typical sense of having an entry in the Add-in menu of the tool bar.
>
>    PLSS is really a set of forms in the PLSS which the security administrator uses to set up security, but mostly (on a day to day basis to the user) it is a security framework that forces a user log in, associates a user with a group or groups, associates application forms with a group / groups and controls the forms based on a VENN diagram intersection of the user's groups and the form's groups. IOW it emulates Windows Security system for Access objects.
>
>    I really do not know how your "add-in factors" relate to using the forms stored in the library to access data stored in the FE.  The actual code in the library pretty much just works for my purposes.
>
>    I have been doing this kind of thing since somewhere around 2001.
>
>    Access 2K brings some interesting challenges as it has a bug relating to circular references between a form pointing to a class which sinks events for the form.  That bug was fixed in Access 2002.
>
>    The PLSS is now working at the form level, for Access 2002 and above, and I have a test / demo database which exercises the user / group / form security in a realistic (if small) environment.
>
>    John W. Colby
>    www.ColbyConsulting.com
>
>
>    A.D. Tejpal wrote:
>    >  AddIns
>    >  =====
>    >
>    >  J.C.,



More information about the AccessD mailing list