From: Mat on
>>Mat, if you don't need to have multiple instances of a form open, why do you need your own collection?

My situation is multiple instances of multiple forms. In fact I
decided to open every form as an instance of that form. It is probably
pushing access to far?

>>Access maintains a collection of open forms. It's called Forms. You can locate a form if you know its name with:
>>Forms(strFormName)

My understanding is that one should create and use their own
collection when working with instances of a form. When you create a
form in a procedure it gets added to the Forms collection for that
temporary time and removed when it goes out of scope so you pass the
instance of the form to a collection to keep it.

>>I never heard of a way to create a class instance without using the literal class name with New

It is a bit irritating there isn't a function, that you can pass a
parameter to, to open a form.

>> think it would be easier to have a separate procedure with its own collection for each form with multiple instances.
>> OTOH, its your code and if you prefer combining all of them in a single collection, who am I to object. Either way, I
>> believe you will need to add/modify some code for each form.

I was kind of experimenting. Either solution has the same core problem
of when you create a new form you have to create new code to manage
it.

Thanks for the replies to date. They are much appreciated.
From: Allen Browne on
Okay: if you are working with multiple instances, then the Forms collection
is not adequate for distinguishing between them, so you do need your own
collection.

The need for multiple instances is pretty rare. Very few of my production
databases use them, so I wouldn't consider it an ideal way to handle forms
in general. Further, my experiments with multiple instances of reports has
not been too productive, so I don't use that at all.

It would be handy if we could use a variable name with the New keywords for
the Form_Form1 thingy, but I never followed that through either.

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.


"Mat" <matthew.kay(a)optusnet.com.au> wrote in message
news:d20d3963-c96f-41c6-bf11-3d6604e50526(a)k5g2000pra.googlegroups.com...
>>>Mat, if you don't need to have multiple instances of a form open, why do
>>>you need your own collection?
>
> My situation is multiple instances of multiple forms. In fact I
> decided to open every form as an instance of that form. It is probably
> pushing access to far?
>
>>>Access maintains a collection of open forms. It's called Forms. You can
>>>locate a form if you know its name with:
>>>Forms(strFormName)
>
> My understanding is that one should create and use their own
> collection when working with instances of a form. When you create a
> form in a procedure it gets added to the Forms collection for that
> temporary time and removed when it goes out of scope so you pass the
> instance of the form to a collection to keep it.
>
>>>I never heard of a way to create a class instance without using the
>>>literal class name with New
>
> It is a bit irritating there isn't a function, that you can pass a
> parameter to, to open a form.
>
>>> think it would be easier to have a separate procedure with its own
>>> collection for each form with multiple instances.
>>> OTOH, its your code and if you prefer combining all of them in a single
>>> collection, who am I to object. Either way, I
>>> believe you will need to add/modify some code for each form.
>
> I was kind of experimenting. Either solution has the same core problem
> of when you create a new form you have to create new code to manage
> it.
>
> Thanks for the replies to date. They are much appreciated.

From: Mat on
> Okay: if you are working with multiple instances, then the Forms collection
> is not adequate for distinguishing between them, so you do need your own
> collection.
>
> The need for multiple instances is pretty rare. Very few of my production
> databases use them, so I wouldn't consider it an ideal way to handle forms
> in general. Further, my experiments with multiple instances of reports has
> not been too productive, so I don't use that at all.
>
> It would be handy if we could use a variable name with the New keywords for
> the Form_Form1 thingy, but I never followed that through either.

I agree the need is rare, it began with experimenting with collections
and so on. Right now I enjoy the feel the user gets from having say a
project database and two different projects open at once in two
instances of the project form. I know they could both be open in one
form ....

I am pretty certain that I will end up using the docmd method of
opening forms in the end. I generally prefer to work with access than
fight against what it is offering for to long.
From: hbinc on
On Mar 11, 6:15 am, Mat <matthew....(a)optusnet.com.au> wrote:
> Thanks for the corrections I was sloppy with the notation.
>
> >> and there is no guarantee that Forms(Forms.Count-1)
>
> I didn't know that. That gives me something to test, because I might
> need to search through the collection for the right form.
>
> The reason is that my collection of forms is not the same form.
> Depending on what is clicked one of several forms will open and get
> stored in the collection. This has led me to create a select case
> statement based upon a string.
> select strFormName
> case "A":
>  set frm = new Form_Form1
> case "B":
> set frm = new Form_Form2
> 'add to the collection to preserve it
>
> However this means updating the case statement with every new form I
> wish to create.
>
> I was hoping to avoid the select case statement by opening the form
> using the docmd.openform statement and pass the strFormName to that
> then point to it then add it to the collection.

Hi Mat,

I have been puzzling on your problem for som time to try to understand
what you are aiming for.
I think I miss some point, because I can not translate it to some
practical situation that I use.
Why you want or need instances of a form, while you can open a form
with DoCmd.OpenForm?


HBInc.
From: Mat on
> Hi Mat,
>
> I have been puzzling on your problem for som time to try to understand
> what you are aiming for.
> I think I miss some point, because I can not translate it to some
> practical situation that I use.
> Why you want or need instances of a form, while you can open a form
> with DoCmd.OpenForm?
>
> HBInc.

Honest answer. All the 'books' talk about opening instances of a form.
I don't think it is necessary to do this for nearly any application
other than developer preference. Anyone else got a good reason for
opening multiple instances of a form?
First  |  Prev  |  Next  |  Last
Pages: 1 2 3
Prev: Reassigning numbers
Next: Returning Only Blank Values