subform subform to control subform

brsawvel

Registered User.
Local time
Yesterday, 22:40
Joined
Sep 19, 2007
Messages
256
Hello,

I've successfully used the following code to allow buttons on one subform to control the source object of another subform:

frm1
subfrm1 subfrm2
buttons controlled source object

Code:
me.parent.subfrm2.sourceobject = frm2
me.parent.subfrm2.form.requery

Now I'm trying to allow subform buttons within a subform to control the source object of another subform and am obviously unable to use the same code.

frm1
subfrm1 subfrm2
subsub1 controlled source object
buttons

I even tried unsuccessfully using this code:

Code:
me.parent.frm1.subfrm2.sourceobject = frm2
me.parent.frm1.subfrm2.form.requery

Anyone know how I can accomplish what I'm trying to do?

I'm sure someone will probably ask why I don't just do a cascading list box, but I don't want to for good reason.
 
Last edited:
If I am following correctly, you have a main form with a subform1 and it has a subform on subform1 (let's call it subform1a). You also have a subform2 on your main form.

You want the subform1a to control the source of subform2, is that correct?

Before I go into this, here's a tutorial I created on subforms which might help in the understanding, and of why I'm going to do it this particular way.
http://www.btabdevelopment.com/main...rhowtoreferencesubforms/tabid/76/Default.aspx

Me.Parent.Form.Parent.Controls("subform1a").SourceObject = "frm2"
Me.Parent.Form.Parent.Controls("subform1a").Form.Requery

Now, you SHOULD be able to refer to it this way too:

Forms("frm1").Controls("subform2").SourceObject = "frm2"
Forms("frm1").Controls("subform2").Form.Requery
 
If I am following correctly, you have a main form with a subform1 and it has a subform on subform1 (let's call it subform1a). You also have a subform2 on your main form.

You want the subform1a to control the source of subform2, is that correct?

You are correct on this assumption. I'm looking at your webpage now to try and figure it out so I'm not just copying and pasting(I tried the codes you offered, but couldn't get them to work).


xxxxxxxxxxxxxxxxxxxxxxxxx

Oh, except that subform1a (the form, not the container) has a button in it that "On Click" sets the source code for subform2. (Rather than subform1a itself being the control.
 
Last edited:
Oh, except that subform1a (the form, not the container) has a button in it that "On Click" sets the source code for subform2. (Rather than subform1a itself being the control.
I gathered that the code would be on the On Click event of the button on Subform1a.

So, if you can't end up getting it, see if you can post the db here and I'll take a look.
 
I figured out the problem (I think) using your website! You offered the following code:

Me.Parent.Form.Parent.Controls("subform1a").Source Object = "frm2"
Me.Parent.Form.Parent.Controls("subform1a").Form.R equery

But I think you accidentally left out this:

Me.Parent.Form.Parent.Form.Controls("subform1a").Source Object = "frm2"
Me.Parent.Form.Parent.Form.Controls("subform1a").Form.R equery

Am I right?
 
Thanks for the help on that one.

Here's a new one, though (if you don't mind). :)

I'm trying to have one form button select the source object of a subform within another open form.

I tried using these but they came back with an error or "object required"

Code:
frm1.subfrm1.sourceobject = "frm2"

subfrm1.form.frm1.form.sourceobject = "frm2"
subfrm1.form.frm1.form.requery
 
I'm assuming that frm1 is your top level parent form and subfrm1 is your subform on that main form, and if so try using this:
Code:
Forms("frm1").Controls("subfrm1").SourceObject="frm2"
Forms("frm1").Controls("subfrm1").Form.Requery
 

Users who are viewing this thread

Back
Top Bottom