Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Tabbed Main Form with Subforms in the Tabs

Status
Not open for further replies.

BikeToWork

Programmer
Jun 16, 2010
50
0
0
US
How does one go about doing this? I have a main table (tblMain) with several other tables related to tblMain in one to many relationships. Is it possible to have a tabbed form object with the main form (tblMain data) in one tab and subforms in other tabs of the same form for the related tables? I've tried doing this and get an error message about "Can't build a link between unbound forms," when I try to link fields, even though both forms are bound. Does the subform have to physically be inside it's master form to work? Thanks in advance for any advice.
 
If the main form is unbound and you want to link two subforms on the main form.
1)Put a hidden textbox on the mainform called "txtbxLink"
2)In the first form's on current event
me.parent.txtbxlink = me.somePkfield (this is the field to link to)
3)in the second and subsequent subforms
master link fields: [txtBxLink]
child link fields: [field to link]

This technique allows you to even link continous subforms.
 
MajP, thanks for the response. The main form and subforms are all bound. That's why the error msg makes no sense. However, the subform is not physically inside the main form. The main form and sub form are on the same tab control, but different pages. What I'd like to do (if this is even possible) is use a tab control with the main form on one tab and linked subforms on subsequent tabs. I just can't figure out how to link the main and sub forms when I get the error message about "can't link unbound forms" when I try.
 
Tabs should have no effect. So what you want to do is possible. The wizard often gets in the way, and I just hit cancel and do it by hand.

Please provide the the main forms recordsource.
 
The main form's recordsource is Select * from tblMain. There is a PK field in tblMain called Autonum that exists as a foreign key in all related tables, including tblConsent. If I take the form named frmConsent based on Select * from tblConsent and drop it directly on the main form, it lets me select the linking fields and even knows what they should be based on the table relationships. If I take the same frmConsent and place it in a tab control object which also contains the main form on a different tab, I keep getting the message about "can't link unbound form," even though both forms are linked. How would you do this by hand? If I simply place frmConsent on a new tab, the database thinks it is a regular form and not a subform. Thanks for your advice on this.
 
BikeToWork,
It really sounds like both your Master and Child forms are subforms on a main form (forget about tabs). If this is true, then MajP has provided the solution that I use regularly.

Don't expect the wizard to work for you. You can just type the values in as suggested by MajP.

Duane
Hook'D on Access
MS Access MVP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top