By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,479 Members | 2,260 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,479 IT Pros & Developers. It's quick & easy.

Replace Subform

P: n/a
Hi Guru's,
What I am trying to achieve is a main form with buttons down the left
side and the rest of the form filled with a sub form. When one of the
buttons is clicked, the sub form with be populated with a corresponding
form. What I think is needed is to update the source object of the subform
but I have no clue on how to do this! Any offers?

TIA,

Mark
Nov 13 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Rog
One way of doing this is putting all your subforms on top of each
other, make them hidden (set the visible property to no), then make one
of them visible, and the others hidden, when one of the buttons is
clicked. In the OnClick event of the button you would have
Me!Subform1.Visible = True
Me!Subform2.Visible = False
Me!Subform3.Visible = False, etc.

Nov 13 '05 #2

P: n/a
If your relationships are clearly defined then you can simply change
the subform in code and you dont even have to worry about Master /
child link fields. This code works fine for me:

me.myChildControlName.ObjectSource = "myNewFormName"
me.myChildControlName.Requery

If you dont have defined relationships between the underlying tables /
queries in the forms, then you may have to set the Master and Child
Link fields...

me.myChildControlName.LinkMasterFields = "Ref Key"
me.myChildControlName.LinkChildFields = "Foreign Key"

Another approach might be to use tabs instead of buttons with a subform
in each tab Or as Rog suggested, hiding and making visible various
subforms - but remember: the more subforms you have open at once, the
slower your form will be.

Nov 13 '05 #3

P: n/a
Thanx for your suggestions. I managed to achieve what I wanted with
Me.SubFormName.SourceObject = "Form_Name"

Thanks again,

Mark

"BillCo" <co**********@gmail.com> wrote in message
news:11*********************@g14g2000cwa.googlegro ups.com...
If your relationships are clearly defined then you can simply change
the subform in code and you dont even have to worry about Master /
child link fields. This code works fine for me:

me.myChildControlName.ObjectSource = "myNewFormName"
me.myChildControlName.Requery

If you dont have defined relationships between the underlying tables /
queries in the forms, then you may have to set the Master and Child
Link fields...

me.myChildControlName.LinkMasterFields = "Ref Key"
me.myChildControlName.LinkChildFields = "Foreign Key"

Another approach might be to use tabs instead of buttons with a subform
in each tab Or as Rog suggested, hiding and making visible various
subforms - but remember: the more subforms you have open at once, the
slower your form will be.
Nov 13 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.