Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Exposing forms to code in library database

Status
Not open for further replies.

Broccoli2

MIS
Mar 26, 2001
161
GB
I have a library database (included through references) which contains a number of reusable forms, class objects, and code modules, and a main database. How do I open a form in the library database with a subform from the main database? It seems Access form objects aren't 'exposed' enough for this - is there a solution?

A lifetime's supply of Oxygen to anyone who can help ...
 
AFAIK the library db approach is only useful for the nodules in the 'library' db. You CAN open the "library" db with command line arguments to show a specific form or report.
MichaelRed
redmsp@erols.com

There is never time to do it right but there is always time to do it over
 
I can 'get to' the relevant objects, but my problem is arranging these in a form/subform relationship. Is there a way of setting the source object for a subform directly to a Form object?
 
My approach to this is usually to have the recordsource object of the form (subform) be a single fixed query, and to manipulate the sql property of THAT query to have the relevant info. In the simplistic case, assume the report (subreport) recordsource is 'qryMyInquiry'. Then, before opening the report (subreport), set the sql of qryMyInquiry to something based on criteria:

Select Case MyCriteria

[tab]Case Is = "FirstChoice"
[tab][tab]qdfMyInquiry.Sql = "Select * from tblFirstChoice;"

[tab]Case Is = "ScndChoice"
[tab][tab]qdfMyInquiry.Sql = "Select * from tblScndChoice;"

[tab]Case Is = "ThridChoice"
[tab][tab]qdfMyInquiry.Sql = "Select * from ThridChoice;"

End Select


MichaelRed
redmsp@erols.com

There is never time to do it right but there is always time to do it over
 
Unfortunately its the actual forms I'm trying to bring together in a form with subform, not just the recordsets. Thanks for your comments though. I'm coming to the conclusion that it just isn't possible :-(
 
? what do you mean " ... actual forms ... " ?

Are you attempting to "assign" the subform to the main form via it's 'name'??

If so, I would think that a similar approach could be made to work, although it might be a bit "kludgish".

In the select case statement you could copy any of the optional (sub)forms to the single subform named as the subform for the report. If there is any Link field, it would have to exist on ALL of the subforms.
MichaelRed
redmsp@erols.com

There is never time to do it right but there is always time to do it over
 
Here are some more details:

I have a library database containing a 'wrapper' module which creates a new custom class object (which I have called 'Dialog'). This object in turn depends on a form 'frmDialog' in the library database. This form includes an unbound subform control, and various search boxes, buttons etc. The idea is that it adds a standard easy-to-use interface to any other form I choose. This all works fine in my library database, and I can assign the subform to any other form I want to 'Dialog-ise'.

No problems so far. Now when I start a new project and include a reference to my library database, I can create my custom class object ('Dim MyDialog As New Dialog'). All fine so far.

Now I want to set the subform of frmDialog (through the Dialog object) to a form in my main project. My Dialog object has a 'Property Get' to provide access to the subform control on frmDialog. Unfortunately, I cannot set the SourceObject property of the Subform control on frmDialog to anything other than a form in the original library database - it just refuses to 'see' any forms in the main database. Although I have access in VB to the form objects for both frmDialog and the form I want to be its subform, I cannot set the Subform control to join them.

I hope this rather longwinded explanation makes things a bit clearer. If you could provide a little more detail about your suggestion (including the subform in the SQL Select?) I would appreciate it. Thanks for your help.

-Rob
 
I will think on it some more. My previous posts were all from the perspective of changing the recrodsource for a form, which may me done in several different ways. With your latest info, My first thought would be to make the foregin form an OCX control, and simply add it to the references. But I need to let this one rattle around in the empty spaces for a while.


MichaelRed
redmsp@erols.com

There is never time to do it right but there is always time to do it over
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top