Referring to control on subform

J

jdberman

I am having an issue with how to refer to a control on a subform from
within the subform itself in a SQL query. I know how to do this
ordinarily, but the case I am dealing with is a little more
complicated. Originally, I had a form [Customer List]. [Customer
List] had two subforms, [Customer Ship To List] and [Customer Product
List]. The two controls of interest on [Customer Product List] are
called ProductName and ProductCode. ProductCode is a Combo Box that
filters by ProductName. Since it is on a subform of [Customer List],
in the query for the combo box, I had to refer to ProductName as Forms!
[Customer List].Form![Customer Product List].Form!ProductName.

None of this created any problems until I had to make [Customer List]
a subform of another for [Customer Parent]. Now I need to have the
query refer to Forms![Customer Parent].Form![Customer List].Form!
[Customer Product List].Form!ProductName for it to work when [Customer
Parent] is open. But of course it will not work when just [Customer
List] is open. Is there a way to refer to an item on the subform
without referring directly to the entire tree of parents?

Thanks for any help that can be offered.
 
D

Damon Heron

You could add an unbound textbox to your subform. Have your sql "Where
ProductName = [textbox1] "
Then in the current event of the subform,

Me.Textbox1 = Me.ProductName
Me.yourCombobox.Requery

Damon
 
J

jdberman

Yay! That worked. Thank you for your help.

You could add an unbound textbox to your subform. Have your sql "Where
ProductName = [textbox1] "
Then in the current event of the subform,

Me.Textbox1 = Me.ProductName
Me.yourCombobox.Requery

Damon


I am having an issue with how to refer to a control on a subform from
within the subform itself in a SQL query.  I know how to do this
ordinarily, but the case I am dealing with is a little more
complicated.  Originally, I had a form [Customer List].  [Customer
List] had two subforms, [Customer Ship To List] and [Customer Product
List].  The two controls of interest on [Customer Product List] are
called ProductName and ProductCode.  ProductCode is a Combo Box that
filters by ProductName.  Since it is on a subform of [Customer List],
in the query for the combo box, I had to refer to ProductName as Forms!
[Customer List].Form![Customer Product List].Form!ProductName.
None of this created any problems until I had to make [Customer List]
a subform of another for [Customer Parent].  Now I need to have the
query refer to Forms![Customer Parent].Form![Customer List].Form!
[Customer Product List].Form!ProductName for it to work when [Customer
Parent] is open.  But of course it will not work when just [Customer
List] is open.  Is there a way to refer to an item on the subform
without referring directly to the entire tree of parents?
Thanks for any help that can be offered.
 

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

Similar Threads


Top