Charlotte Foust
cfoust at infostatsystems.com
Mon Jun 26 10:50:30 CDT 2006
You have to add the forms to a collection as you open them, John. Microsoft used to have a Forms sample database that contained an example of a way to do this. Nothing built in, but you could easily build your own class to handle it. Charlotte Foust -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of JWColby Sent: Sunday, June 25, 2006 6:36 AM To: 'Access Developers discussion and problem solving' Subject: Re: [AccessD] Loading more than one instance of a form Eric, This is what I meant when I said that there was a document collection somewhere. I used to use this syntax when I built a widget for working on forms in design view. Unfortunately, that does not solve the problem of getting a handle to the form opened. If you run Docmd.Open doc.name ONCE then you can get a handle to that form using currentdb.forms("FormNameJustOpened"). Unfortunately if you open the same form several times using that same syntax, Docmd.Open doc.name Set MyFormPointer1=currentdb.forms("FormNameJustOpened") Docmd.Open doc.name Set MyFormPointer2=currentdb.forms("FormNameJustOpened") Does not work Apparently the forms all go into the currentdb.forms() collection, but because they all have the same name, the second instance cannot be retrieved. Or perhaps the second instance is never instanced at all? I have never actually looked at currentdb.forms().count to see if the second and subsequent instance ever actually makes it into that collection. In any event I can't get a pointer to the second and subsequent form instance which is my objective. I can open multiple instances till the cows come home using Dim MyFormCollection as collection While 1 Set MyFormPointer = form_MyFormName MyFormCollection.Add MyFormPointer Wend BUT... Set MyFormPointer = form_MyFormName Means I have hardcoded the set statement to the name of ONE SPECIFIC FORM form_MyFormName The reason I am trying to do this is that (for example) if you had a bunch of list tables consisting of a PK and a field (CI_ID, CI_CityName)... You could build a single list form, open that form, change the recordsource and bind the controls to the two fields, whatever they may be. Thus you could be have one form for every list table with just two fields instead of a new form for each. That is just one example of where this would be useful. John W. Colby Colby Consulting www.ColbyConsulting.com -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of StaRKeY Sent: Sunday, June 25, 2006 8:54 AM To: 'Access Developers discussion and problem solving' Subject: Re: [AccessD] Loading more than one instance of a form John, Is this what you're looking for? You can open or change forms, reports, modules etc... Without them being open! Sub John Dim doc as doa.document, db as dao.database Set db=Currentdb For each doc in db.containers("forms").documents debug.print doc.name docmd.open doc.name,acDesign,acHidden 'do whatever you want in designmode docmd.close doc.name, True (save changes) Next doc Set db=nothing Set doc=nothing End sub Forms = forms Reports = reports Macro's = scripts Modules = modules (moduletype ==> module or classmodule) Regards, Eric -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com