Child Forms and .isLoaded

A

Adrian Jones

I have a question about the .isLoaded flag and subForms.

In A2K I have a Form, let's call it frm_MainForm which contains a child
form, which we'll call frm_ChildForm.

If I open frm_MainForm then the child form also opens. Of course it does, I
can see it.

If I check CurrentProject.AllForms("frm_MainForm").isLoaded I get True.

If I check CurrentProject.AllForms("frm_ChildForm").isLoaded I get False.

Is there a way to check the .isLoaded status of a child form without
scanning through the Forms collection, recursing through the .controls to
find all the sub-forms and sub-sub-forms and compare the name?

Thanks,

Adrian
 
A

Albert D. Kallal

Is there a way to check the .isLoaded status of a child form without
scanning through the Forms collection, recursing through the .controls to
find all the sub-forms and sub-sub-forms and compare the name?

Not really. I think you are confused by what a sub-form is!!!

A sub-form is simply a contorl that you place on a form.

Eg:
If I have a form that is attahed to a table called cutomers, then I can
place a text box contorl on the form, and call it zoo1

zoo1

I can then set the data souce of that above contorl to company name.

Now, I can place another cntorl on the form, and call it

zoo2

I can then set the data souce of that above contorl to company name.

What this means is that I cna have TWO contorls on the SAME form, and bind
them to the saem field.

The same thing occurs with a sub-form. I could have palce two sub-form
contorls on the form, (called them zoo1, and zoo2). You cna set set WHAT
FORM this sub-form contorl is attached to. Note hat you BOTH CONTORLS can be
set to the SAME form that you plan to use for the sub-form (you will see the
from two times on your form!!!).

So, which exalcity version of teh sub-form do you want to know is laoded?
You cna have muoplate instances of the smae form laoded over and over (in
fact that is how I created my calendar form!!).

You see an example of the calender form here:

http://www.kallal.ca/ridestutorialp/setdriver.htm

Note that this means I have 42 SUB-FORMS!! and, they are ALL the same
form!!! (by the way, using this concept means you can builds a way cool
programmable calendar form in just a few hours of time!!).

So, all of the above begs the question, and that question is WHAT copy of
the sub-form do you want to know is loaded..and why?

Since there can be as my example shows 42 copies of the same form loaded,
then really the isloaded() is of no use?

For what reason do you need to check if the sub-form is loaded? (why not
check if the main form is loaded that has the sub-form control?). That would
be MUCH better, as you can't just referenced the forms() collection for a
sub-form, since you don't know what copy of the sub-form is loaded! (a
sub-form creates a NEW INSTANCE of the sub-form).

You might want to expand on why you need this information, but if you have
two forms open, and they both have the same sub-form, then you have two
copies of the sub-form running. (and, all of their code, variables etc. has
a complete separate set of values...they don't interfere with each other).

Knowing that a form is being used as a sub-form is really of no value, since
you don't know WHICH copy you are going to reference (and, further, the
sub-form is NOT added to the forms collection when loaded as a sub-form --
it would not make sense to do so either!!!).

So, do expand perhaps on what you are trying to accomplish here, but it
seems to me the way to check here is to simply check if the main form is
loaded....
 
A

Adrian Jones

Albert D. Kallal said:
You might want to expand on why you need this information

Hi Albert,

Thanks for the reply. I thought I might end up having to explain exactly
what I'm doing, but hoped that a simple example might've sufficed. :/

I don't need to identify specific instances of a form, it's the structure of
the form itself that I'm trying to access.

I'm re-organising a database that has been developed on an ad-hoc basis for
the last year, and trying to create a uniform naming style for the queries,
forms and reports.

But to rename a query I need to know which other queries, forms and reports
are using it.

Finding the queries is fairly trivial. Finding the forms that use a
particular query is more problematic. (I haven't even thought about the
reports yet!)

I'm opening each form as acHidden (since this can't be done when they're
closed), scanning through the controls for comboBoxes, pulling out their
rowSource, then closing the form. Obviously this causes problems with any
forms that are already open, so I put a check in to skip the open and close
when the form's .isLoaded flag was set.

Now, whereas .isLoaded is True when a form is opened normally, it's False if
that form has been opened as a sub-form. So the form I'm checking opens. And
consequently the parent form closed itself.

So far, the only way around this seems to be to generate a list of all the
open forms, including those openend in sub-forms (that's easy to do) then
scan the open forms separately, then work on the closed forms, ignoring forms
whose name is in that list.

I thought that as there's a .isLoaded flag, it would apply to any form that
was loaded, no matter whether it was in a sub-form control or not.

Thanks for your help anyway.

Adrian
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top