Solved

TWO TABLES AS SUBFORMS IN ACCESS...HOW DO I LINK THEM?

Posted on 2012-03-22
4
448 Views
Last Modified: 2012-03-24
I have a Microsft Access Solution I am repairing.

I have three tables.

TBL1 is parent to TBL2, and TBL2 is parent to TBL3.

I also have FORM1, which represents TABLE 1 and has the necessary fields.

inside FORM1 is SUBREPORT1 which displays TABLE 2, in a table format for data entry.  Table 2 is linked to Table one via FORM1's Link Master/Child Fields.

I want to integrate Table three.  I want to make a subreport2 which will hold Table three, and have a relationship set (master/child) between Table 2 and Table 3.

Can I do this?  If so, how?

in short, Form 1 represents Table 1.  Subreport 1 represents Table 2 and is Child/Master Locked to Table 1.  I want Subreport 2 added representing Table 3 and lock it Child/Master to Subreport 1.  Both Subreports are on the same Form.

Thanks
0
Comment
Question by:Evan Cutler
4 Comments
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 37755761
Just note that your question here is: "TWO TABLES AS SUBFORMS "

...yet in your posts, you are referring to "subReports"



In any event, I will presume you are using forms.

A three level nested form structure requires a bit of VBA to have it work just right.
The form wizard will create this type of form for you.
Open the form wizard
Select the fields you want from the Parent table
Select the fields you want from the first Child table
Select the fields you want from the second Child table

Then you should be able to click through the rest of the wizard's steps...


;-)

JeffCoachman
0
 
LVL 57

Assisted Solution

by:Jim Dettman (Microsoft MVP/ EE MVE)
Jim Dettman (Microsoft MVP/ EE MVE) earned 250 total points
ID: 37756743
Little trick to this; a master link can be a field or a control.  So here's the setup:

1. Main form and first subform, set master/child links as normal
2. On the main form, create a hiddent control.  Call it something like txtSubform1Key.
3. In the on current event of the first subform, place the key you want to use for subform 2 in the control:

Me.Parent.txtSubform1Key = <some value>

4. Set the master link for subform 2 to  txtSubform1Key and the child link as normal.

That's it!

Jim.
0
 
LVL 30

Accepted Solution

by:
hnasr earned 250 total points
ID: 37758631
Example:
3 tables:
a(aid, adesc)
b(aid, bid, bdes)
c(bid, cid, desc)

1 Main form EE record source a, and display both fields.

2 Create first subform control on form EE, if wizard starts, click cancel. A blank control appears.
   Select Control and choose properties window
   Data Tab
   Record Source: Table.a
   Master Link field: aid
   Child Link field: aid
3 repeat step 2
   Record Source: Table.b
   Master Link field: Child1.bid
   Child Link Field: bid

Check this sample database.
Run EE and watch.
Two-tables-as-subforms.accdb
0
 
LVL 9

Author Closing Comment

by:Evan Cutler
ID: 37760964
Thanks Guys.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article explains all about SQL Server Piecemeal Restore with examples in step by step manner.
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now