jwcolby
jwcolby at colbyconsulting.com
Thu Jul 8 13:59:20 CDT 2004
I have not figured out how to pass in the name of the form to open (that's
what the strFrmName was about). I do know that the form_MyFormName actually
refers to the MODULE behind the form (even if none exists I believe), but I
do not know how to open that module directly by name (causing the form to
open). These modules do not appear to be stored in the modules collection,
and the form does not exist in the forms collection unless it is already
open. If you open it first, you will always end up with a pointer to the
same instance. Sigh.
There is a syntax:
CurrentDb.Containers!Forms.Documents(strFrmName)
That allows you to get at the object as a document or an object. I used to
be able to open a form in design view using this but I don't remember how.
I think it was just opening one instance though, for the purpose of
manipulating design view properties.
At any rate, I do not have the answer as to how to pass in the name of the
form and open it using the Set statement syntax.
John W. Colby
www.ColbyConsulting.com
-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of jwcolby
Sent: Thursday, July 08, 2004 2:24 PM
To: 'Access Developers discussion and problem solving'
Subject: RE: [AccessD] Multi Forms
Actual working code. The key is that opening a form this way only keeps it
open as long as a pointer to the form remains in existence. Thus you have
to save the pointer in a collection to hold it open. The CLOSE of the form
MUST remove itself from the collection or the user will be able to close the
form but a pointer to it will remain, clogging up the works.
I use a string in the caption as the key to the collection, thus the form
can look in it's caption to find the key to its pointer in the collection.
Option Compare Database
Option Explicit
Private colForms As Collection
Private blnFrmsInit As Boolean
Function MyFormOpen(strFrmName As String, strInstanceName As String) Dim frm
As Form
If blnFrmsInit = False Then
Set colForms = New Collection
blnFrmsInit = True
End If
Set frm = New Form_lfrmSpecialtyPreferences
frm.Caption = strInstanceName
colForms.Add frm, strInstanceName
End Function
Function MyFormClose(strInstanceName As String)
colForms.Remove strInstanceName
End Function
Hope this helps.
John W. Colby
www.ColbyConsulting.com
-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Francisco H Tapia
Sent: Thursday, July 08, 2004 1:19 PM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] Multi Forms
Yup, but in my app, i'm going to have to open several instances of the
several forms, I don't want to write up this funciton for every one of
them...
Charlotte Foust wrote On 7/7/2004 4:00 PM:
>Are you trying to open multiple instances of the same form, or what?
>
>Charlotte Foust
>
>-----Original Message-----
>From: Francisco H Tapia [mailto:my.lists at verizon.net]
>Sent: Wednesday, July 07, 2004 1:38 PM
>To: AccessD
>Subject: [AccessD] Multi Forms
>
>
>http://members.iinet.net.au/~allenbrowne/ser-35.html
>
>I'd like to make this code more re-useable but i seem to be stuck at
>this line
>
>I thought I'd be able to pass a variable and then just set the new
>object as a new "form" object. Is this not possible?
>
> Set frm = New Form_frmClient
>
>
>wasn't there a thread not too long ago about multiforms?
>
>
>
--
-Francisco
--
_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com
--
_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com