Full Version: Refer to a subform's control's row source
UtterAccess Discussion Forums > Microsoft® Access > Access Forms
TheOtherDodge
Main form: frmSelectEmpsExistingWsub
Subform on Main form: frmSelectEmpsExistingSubExisting
Control on subform: lstExistingEmps

I want lstExistingEmps.RowSource = strSQL1

Thanks!
Bob_L
Forms!frmSelectEmpsExistingWsub.frmSelectEmpsExistingSubExisting.Form.lstExistin
gEmps.Rowsource = strSQL1

But, make sure you use the name of the subform container control (control on the main form that houses the subform on the main form) on the main form instead of the subform name. They might be the same, which is okay, but if not you need to use the subform container name and not the subform name.
Bob_L
Oh, and here's a couple of reference sources:

http://www.mvps.org/access/forms/frm0031.htm

http://www.btabdevelopment.com/main/QuickT...76/Default.aspx
accesshawaii
Take a look at the attached database.
TheOtherDodge
Thanks everyone! I got it. Man it can get confusing when having to refer to subforms, etc.
Bob_L
QUOTE
Man it can get confusing when having to refer to subforms, etc

It doesn't have to be. It really comes down to three simple principles:

1. When you are dealing with subforms, you are actually dealing with two parts - the subform CONTAINER (that which houses the subform on the main form) and the subform itself.

2. The subform and subform container can be named the same, but are not necessarily so. You need to check before writing the code. If they are the same then it simplifies things but it doesn't really matter if it is, or isn't, because you just have to refer to the container.

3. When you are doing things, like setting the recordsource on the subform, you are not really requerying the container, as it doesn't have a requery method, but the subform itself does. So, when you are referring to a property, or method, on the actual subform (not the container), you need to have the subform container name and then .Form. between the container name and the method, or property, so Access knows you want to refer to the form's method or property and not the container's method or property.
manrav1
Mr Larson,
Say I am on the main Form.
How to I find the Sub form container name? (assuming there is only 1 sub form)


Just trying to learn more about the Container.

TIA

Rav
accesshawaii
Glad you got it working.
Bob_L
QUOTE
Mr Larson,
Say I am on the main Form.
How to I find the Sub form container name? (assuming there is only 1 sub form)


Just trying to learn more about the Container.

TIA

Rav

If you go to this link for my "quick tutorial" and look at the screenshot it shows how you know:
http://www.btabdevelopment.com/main/QuickT...76/Default.aspx
manrav1
Thank you Thank you
Amazing Tutorial

For so many projects I have been using steps that are not needed.
And have also been advising users the same, in my efforts to help.

This really helps

Thank you so Much

Learn so much every day on this forum


Rav
uarulez2.gif thanks.gif
Bob_L
QUOTE
Thank you Thank you
Amazing Tutorial

For so many projects I have been using steps that are not needed.
And have also been advising users the same, in my efforts to help.

This really helps

Thank you so Much

Learn so much every day on this forum


Rav
uarulez2.gif thanks.gif


Glad we could help with that. Glad you are getting things out of the forum. I know I do all of the time too.

thumbup.gif
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.