Referencing a multiply instanced form in a query

K

KitCaz

Allen Browne's tip on creating multiple instances of a form
(http://allenbrowne.com/ser-35.html) was the best resource I found on the
subject!

I have one other question if someone can direct me where to find it--

Now that I've instanced the forms and added them to my clnClient collection,
I'm a bit unclear how I can self-refer to this instance in a rowsource query
statement for a field on the form. E.g. I have a field on my form which is
referenced in the query statement of another field by using the syntax
[Forms]![MyForm]![MyField]. Of course this qualifier is now ambiguous. How
can I adjust this syntax such that the statement applies to the current
instance instead? Something akin to [Me]![MyField] or [Parent]![MyField] but
these don't work. Maybe I need to be using my custom collection but I'm not
sure of the sytnax to get the current window handle into it, e.g.
[clnClient].(hwnd)![MyForm]![MyField] (also not working).

Anyone' best advice here?

Chris
 
D

Dirk Goldgar

In
KitCaz said:
Allen Browne's tip on creating multiple instances of a form
(http://allenbrowne.com/ser-35.html) was the best resource I found on
the subject!

I have one other question if someone can direct me where to find it--

Now that I've instanced the forms and added them to my clnClient
collection, I'm a bit unclear how I can self-refer to this instance
in a rowsource query statement for a field on the form. E.g. I have
a field on my form which is referenced in the query statement of
another field by using the syntax [Forms]![MyForm]![MyField]. Of
course this qualifier is now ambiguous. How can I adjust this syntax
such that the statement applies to the current instance instead?
Something akin to [Me]![MyField] or [Parent]![MyField] but these
don't work. Maybe I need to be using my custom collection but I'm
not sure of the sytnax to get the current window handle into it, e.g.
[clnClient].(hwnd)![MyForm]![MyField] (also not working).

Anyone' best advice here?

Chris

You can't use a string index to the Forms collection, because
non-default instances of forms aren't indexed by name. Is this the
form's recordsource query you're talking about? Maybe you can get
around it by assigning the recordsource dynamically, building the SQL
string in code and embedding values taken from the form's controls.

If the form instance happens to be the active form, maybe you can use
Screen.ActiveForm!MyField to refer to the control on the form. But the
timing of that for any practical purpose is going to be tricky.

Another possibility might be to write a public function to which you
would pass the form's hWnd and the name of the control whose value you
want, and which would go to your collection to get the form reference
and, from that, the control value. The function would then pass back
the control value.

These are just ideas. I haven't tried any of them.
 

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