468,140 Members | 1,635 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,140 developers. It's quick & easy.

Passing Parameter Problem when using Display Form...

I've got a form - "frmLookup" (with a subform) that works very happily
on its own. The form has a list box, which when updated requeries the
subform to display the appropriate results.

The problem is that for the final user interface, I had planned to use
a "frmDisplay" form which had a number of menu items and then depending
on what the user selected, it would display the appropraite form in a
subform beneath the menu items. I did this mainly for ease of
controlling the window location, less frightening to the user and also
to avoid a mass of pop-ups. However, when I try to display "frmLookup"
in this subform, the subform within "frmLookup" can no longer find the
listbox I referenced as Forms.frmLookup.lstGroup. I couldn't get the
right reference for it to work through the second sub form. Even if I
did, I would like to be able to run "frmLookup" on it's own as well as
through the display subform.

Does anyone have any ideas if this is possible and if so how - I
thought functions might work but didn't have a lot of luck returning a
"lstGroup" value (is that possible from a public function in a module??
Or failing that, what would the correct reference be to reference the
lstbox in "frmLookup".

Cheers,

Reg

Dec 14 '06 #1
4 1790
okay, for ease of communication, let's forget the frmDisplay for a minute
and speak strictly in the context of frmLookup and its' subform.

if you're working with VBA code (not a macro), and you are in the subform's
module, and you want to refer to the listbox control on the main form
(frmLookup), then use the following syntax, as

Me.Parent!lstGroup

the above syntax will work even when frmLookup becomes a subform, itself.

however, if you're not referring to lstGroup from within a VBA module, then
you're going to have to refer to lstGroup with the full reference, as

Forms!frmDisplay!SubformControlName.Form!lstGroup

replace SubformControlName with the correct name of the subform control that
"contains" frmLookup, of course. this solution precludes using frmLookup as
a stand-alone form, unfortunately - unless you're using the reference in the
subform itself (not in a macro); then you might be able to use the

Forms!frmLookup!lstGroup

syntax in the subform, and write code in frmDisplay's Load event to change
to the longer reference posted above.

hth
"Regnab" <p.*******@gmail.comwrote in message
news:11**********************@l12g2000cwl.googlegr oups.com...
I've got a form - "frmLookup" (with a subform) that works very happily
on its own. The form has a list box, which when updated requeries the
subform to display the appropriate results.

The problem is that for the final user interface, I had planned to use
a "frmDisplay" form which had a number of menu items and then depending
on what the user selected, it would display the appropraite form in a
subform beneath the menu items. I did this mainly for ease of
controlling the window location, less frightening to the user and also
to avoid a mass of pop-ups. However, when I try to display "frmLookup"
in this subform, the subform within "frmLookup" can no longer find the
listbox I referenced as Forms.frmLookup.lstGroup. I couldn't get the
right reference for it to work through the second sub form. Even if I
did, I would like to be able to run "frmLookup" on it's own as well as
through the display subform.

Does anyone have any ideas if this is possible and if so how - I
thought functions might work but didn't have a lot of luck returning a
"lstGroup" value (is that possible from a public function in a module??
Or failing that, what would the correct reference be to reference the
lstbox in "frmLookup".

Cheers,

Reg

Dec 14 '06 #2
Thanks Tina,

Your suggestion of using Me.Parent!lstGroup worked a treat when I used
it in a function is the subform's module, and then called it to supply
the default value of one of the text boxes in the sub form (txtGroup).
This doesn't appear to work however when I try to call the function to
supply a criteria in the subfrm's source query. Am I doing something
incorrectly or is it not possible to call a frm specific function from
the query?

Cheers

Reg

tina wrote:
okay, for ease of communication, let's forget the frmDisplay for a minute
and speak strictly in the context of frmLookup and its' subform.

if you're working with VBA code (not a macro), and you are in the subform's
module, and you want to refer to the listbox control on the main form
(frmLookup), then use the following syntax, as

Me.Parent!lstGroup

the above syntax will work even when frmLookup becomes a subform, itself.

however, if you're not referring to lstGroup from within a VBA module, then
you're going to have to refer to lstGroup with the full reference, as

Forms!frmDisplay!SubformControlName.Form!lstGroup

replace SubformControlName with the correct name of the subform control that
"contains" frmLookup, of course. this solution precludes using frmLookup as
a stand-alone form, unfortunately - unless you're using the reference in the
subform itself (not in a macro); then you might be able to use the

Forms!frmLookup!lstGroup

syntax in the subform, and write code in frmDisplay's Load event to change
to the longer reference posted above.

hth
"Regnab" <p.*******@gmail.comwrote in message
news:11**********************@l12g2000cwl.googlegr oups.com...
I've got a form - "frmLookup" (with a subform) that works very happily
on its own. The form has a list box, which when updated requeries the
subform to display the appropriate results.

The problem is that for the final user interface, I had planned to use
a "frmDisplay" form which had a number of menu items and then depending
on what the user selected, it would display the appropraite form in a
subform beneath the menu items. I did this mainly for ease of
controlling the window location, less frightening to the user and also
to avoid a mass of pop-ups. However, when I try to display "frmLookup"
in this subform, the subform within "frmLookup" can no longer find the
listbox I referenced as Forms.frmLookup.lstGroup. I couldn't get the
right reference for it to work through the second sub form. Even if I
did, I would like to be able to run "frmLookup" on it's own as well as
through the display subform.

Does anyone have any ideas if this is possible and if so how - I
thought functions might work but didn't have a lot of luck returning a
"lstGroup" value (is that possible from a public function in a module??
Or failing that, what would the correct reference be to reference the
lstbox in "frmLookup".

Cheers,

Reg
Dec 14 '06 #3
Been playing around with it a little more and worked out that I can do
it by changing the recordsource of the subform before I requery it from
the the lstGroup AfterUpdate on the "frmLookup" form. Unless there are
better suggestions I'll run with this. Thanks for all your help,

Cheers

Reg

Dec 14 '06 #4
This doesn't appear to work however when I try to call the function to
supply a criteria in the subfrm's source query.
normally, a subform loads *before* its' parent form, so the function call in
the subform's RecordSource query is looking for a mainform control that
isn't "there" yet. you might try assigning the subform's RecordSource
property on frmLookup's Load event. once both subform and mainform are open,
subsequent function calls should work okay without special handling.

if the above suggestion doesn't work for you, suggest you just stick with
the solution you've already set up.

hth
"Regnab" <p.*******@gmail.comwrote in message
news:11**********************@f1g2000cwa.googlegro ups.com...
Been playing around with it a little more and worked out that I can do
it by changing the recordsource of the subform before I requery it from
the the lstGroup AfterUpdate on the "frmLookup" form. Unless there are
better suggestions I'll run with this. Thanks for all your help,

Cheers

Reg

Dec 15 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by domeceo | last post: by
1 post views Thread by Paul Fairless | last post: by
1 post views Thread by Michael DeLawter | last post: by
4 posts views Thread by Ron Rohrssen | last post: by
7 posts views Thread by Jason | last post: by
27 posts views Thread by didacticone | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.