link master field with child field

G

Guest

Okay, my prior question was not answered but I asked the wrong question. I
tried to link my subform with my main form by adding the caseID;partyType in
the control source for the form and the subform. This is making the caseID
field weird. It looks instead of linking the fields it is concatenating the
fields and making the caseID have the text fields in it.

What I want is to link the master field with the child fields instead of
create a concatenated key.
tia,
 
P

Pat Hartman \(MVP\)

Make sure that your tables are defined properly. The key to the "master"
table is stored in the "child" table where it is referred to as a foreign
key.

The ControlSource for the main form should be a query that references only
the "master" table (plus joins to any necessary lookup tables). The
ControlSource for the sub form should be a query that references only the
"child" table (plus joins to any necessary lookup tables).

So, I am assuming that CaseID is the primary key of the "master" table and
PartyType is the primary key of the "child" table. The CaseID must be
included in the ControlSource query for the subform. Both the master/child
link fields should be CaseID. That is the field that links the two tables.
 
J

Jeff Boyce

Getting text instead of IDs (or vice versa) make me wonder if your tables
might include "lookup" data types. If so, this could be your issue, since
"lookup" data types store one value but display something else. Confusing,
no?!

--
Regards

Jeff Boyce
Microsoft Office/Access MVP


Microsoft IT Academy Program Mentor
http://microsoftitacademy.com/

Microsoft Registered Partner
https://partner.microsoft.com/
 
G

Guest

PartyType is not the primary key of the child table. But it is a field that
I need.
The primary key is a serial number. ARe you saying I should use the serial
number not the text field?
 
J

John Vinson

I
tried to link my subform with my main form by adding the caseID;partyType in
the control source for the form and the subform.

Forms and Subforms do not HAVE a "control source" property. Textboxes
and other data controls do. See my reply in your other thread.

John W. Vinson[MVP]
 
G

Guest

Pat Hartman (MVP) said:
Make sure that your tables are defined properly. The key to the "master"
table is stored in the "child" table where it is referred to as a foreign
key.
I don't know if you are speaking about having the two fields caseID and
partyTypeID
in both tables? If so I defined the table fields correctly. I just can't
figure out how to link the second field partyTypeID.
The ControlSource for the main form should be a query that references only
the "master" table (plus joins to any necessary lookup tables). The
ControlSource for the sub form should be a query that references only the
"child" table (plus joins to any necessary lookup tables). Okay, I think I follow you.
So, I am assuming that CaseID is the primary key of the "master" table and
PartyType is the primary key of the "child" table. The CaseID must be
included in the ControlSource query for the subform. Both the master/child
link fields should be CaseID. That is the field that links the two tables.
This is where I don't follow you.
I thought you were supposed to define the master link field to the child
link field in the table definitions. i.e. cases table and partyType tables.
In datasheet view I thought you were supposed to put the links but I don't
know which one to put in case ID or partytypeID.

I think I did a query with those two fields. If I am supposed to link the
query to the form I really got lost. Is the query on cases and partytype
tables on the two id fields?
How do I relate the query to the form?

thanks,
 
G

Guest

John:

I read your other post and I replyed to your other link as well.
I found the subform properties but there was no Master field link?
thanks for your help.
 
A

Albert D. Kallal

I thought you were supposed to define the master link field to the child
link field in the table definitions.

A horse is a horse is a horse.....

A table is a table is a talbe..

the ONLY thing you define in the table is fields, primary key, and some
indexs...nothing more, nothig less..
In datasheet view I thought you were supposed to put the links but I don't
know which one to put in case ID or partytypeID.\

Ouch...don't know where you got that idea. The way relatonal databases have
worked for the last 20 some years is that you deinf ehte table, PK, and
perahps some indexes. If you need addotnal ralted talbes, hten yu create
those tables. At this point, to "relate" the tables, you then go

tools->Relatonships

You add in your talbes, and then simply draw the join lines.......

You do NOT define relationships in table design mode, or worse, as you
stated datasheet mode....

Once you defined the relationships, then you simply build forms. Those forms
are USUALLY simply based directly on the table. If you have a related
table, then you can create a sub-form to display this related data. This
"sub-form" is where you set the master link, and master child relationships.
(they are properties in the property sheet for the sub-form control).

Remember, you do want to pay attention to the correct kind of join to use.
In my experience, about 80% (perhaps more) joins should be left joins in an
application.

A left join means that a query will return the "parent" records when the
child table HAS NO correspond record.

So, if we have Customers, and Invoices tables, a left join would give us:

CustomerName InvoiceNumber
AppleBee
Donought Shop 1234
Doughnut Shop 1344

Note how AppleBee does NOT yet have a invoice number in the invoices
table..but the query still returns the record. You also have to use left
joins
for lookup values when you drop in many tables (can't use standard joins in
this case).

Note, when I say lookup values...I don't mean the built-in lookup values.
You WANT TO AVOID those at ALL COSTS.

Please read the folwling..and pay CAREFUL attention to #2 in the list, and
note how we ALL STRONGLY warn against using lookup fields in the table
design mode....

So, with a left join, the corresponding child record DOES NOT have to exist.
Just think of "left" side can exist...but the right side does NOT have to !

A middle join, or so called inner join is the standard join, and BOTH tables
have to have a value for the join. The above would produce:

CustomerName InvoiceNumber
Dounought Shop 1234
Doughutn Ship 1344

So, in the above inner join, our customer name of Applebee does not show,
since that customer does NOT yet have a invoice record in the invoice table.

To make a left join, you drop in the tables (in the query builder, or the
relationship designer), and draw the join line to the appropriate filed
between each table. You then double click on the join line. You then click
on the join type button

You get three options:

Only include rows where the joined fields from both tables are equal
(this standard default inner join)

Include ALL records from "Customers" and only those records from
"Invoices" where the joined fields are equal

(this is our left join. So, our main table Customers will be returned in
this query, REGARDLESS if the child records (invoices in this example)
exist, or not!. This is left join

Include ALL records from "Invoices" and only those records from
"Customers" where the joined fields are equal
This sis obviously a right join....

For forms, and sub-forms, and related tables, left joins are quite
important.

If you look at the following screen shot, you can see that most relations
ships are this left join, and RI is enforced.

http://www.members.shaw.ca/AlbertKallal/Articles/PickSql/Appendex2.html

tblBgroup (booking group) for example may, or may not have payments made
(tblPayments). Thus, you can add a booking group, and NOT have to add child
records. However, full RI is enforced, and you can see the side ways 8
"omega" sign AND THE ARROW HEAD. The simple lookup fields are simply just a
arrow drawn, and no "1", or omega sign exists (tblPayments to tblHowpaid for
example is a simple lookup).

The tables that MUST have a child records can also clearly be seen. If you
go from the tblBgroup to the its parent table, you will see table
tblBooking. You can easily see that there is a 1 to many here also, but NO
ARROW head exists. Thus, when I create a booking, my designs will ALWAYS
ASSUME that a child records in tblBgroup (booking group) will exist (ie: I
must code, and assume that when I add a tblBookin records, my code also
assumes that a tblBGroup will also have to be added).

So, the ER diagram can convey a lot about your designs. Down the road, I can
now look at that diagram, and when writing code, I will know if the design
can, and does assume if child records are required. If you look at that
table, it is VERY RARE that I require the child record. That application has
about 60 tables, and I think only 1 or 2 in the whole thing is NOT a left
join. Hence, you most certainly should set the relation in the window for
future reference, and also it will help you when you create a query, or a
report.
 
J

John Vinson

I read your other post and I replyed to your other link as well.
I found the subform properties but there was no Master field link?
thanks for your help.

Not sure where you were looking. It's pretty easy to select the Form
object *within* the Subform control, rather than the (quite different)
box containing the Subform. Either click the edge of the subform (it
should grow "handles" to indicate that it's been selected) or select
the Subform Control by name from the dropdown box at the left of the
toolbar. The Child Link Field and Master Link Field properties are on
the Data tab of the control's properties.

John W. Vinson[MVP]
 
G

Guest

thanks,
\o/\o/\o/
--
Janis


John Vinson said:
Not sure where you were looking. It's pretty easy to select the Form
object *within* the Subform control, rather than the (quite different)
box containing the Subform. Either click the edge of the subform (it
should grow "handles" to indicate that it's been selected) or select
the Subform Control by name from the dropdown box at the left of the
toolbar. The Child Link Field and Master Link Field properties are on
the Data tab of the control's properties.

John W. Vinson[MVP]
 
A

Albert D. Kallal

FilemakerPro_Developer said:
I have one question for a value list relationship where you want to see
all
the values in a parent table that are in a child table it would be a right
join correct? You want to see all the values on the right and none of the
values on the left matter. Then the user selects from the list.

yes, that seems about right....

However, my brain tends to get confused, so as a general rule, I usually
start at the TOP most table, and work down.....

In most cases, if you plop in the parent table, and child table..and left
join..that tends to be the

same as

if you drop in the child table, and then the parent table..and right
join....

So, which table you start with,and which direction you draw the line makes a
large difference here.......

(actually, the direction you draw the line in tends to make the difference
here, but you can change this by double clicking on the join line when
viewing the tables in the "relationships" window....

By the way, you might find the following article interesting, and in this
article I give some tips as to when moving from a "different" system to
ms-access. while that system was not fileMaker...you will still enjoy the
read..and it is only a few pages:

http://www.members.shaw.ca/AlbertKallal/Articles/fog0000000003.html

in the above, I point out some "got-ya" things that occur in ms-acces.....
 
R

Rick Brandt

FilemakerPro_Developer said:
This is really confusing. I have a mediators table value list. I want to
select from it in cases. It is the 2nd in the join types or the 3rd?

You are having some real problems and answers are coming slowly, mostly (I
believe) because you are stuck it FMP jargon. The phrase "mediators table value
list" has no meaning in Access (at least not to me).

If you have a mediators table, then fine. A Value List in Access is a
semi-colon separated list of values used to supply the RowSource to a ListBox or
ComboBox on a form as an alternative to using a query or table.

Combined together as "mediators table value list" I can make no sense out of
what you are talking about. As to the type of join. That is a decision one
makes when building a query that contains more than one table and a join is made
between two of the tables. Since you have only mentioned one table (I think)
then telling you what kind of join you need is not possible.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top