Relating a Microsoft Access Table to Itself
Good for Head-of-Household, Genealogy Databases, etc.
Q: I�ve now completed through
Access 201. What I�m
faced with is generating a report very similar to the contacts report
done in 104 &
201. I want it to list a
primary member�s name and their information and then also list all the
family members related to them via a relationship.
I�ve created both a PrimaryT, FamilyT, PrimaryF, FamilyF and PrimaryQ.
In the FamilyF I have a drop down box that accesses PrimaryQ where I
choose the primary member�s name that the family member is "related" to.
I�m having difficulty creating a Query that brings the two tables
together because there are common fields between them (like "name").
Without this query I can�t create a report that pulls in related family
members can I? I�ve now completed through Access 201. What I�m faced
with is generating a report very similar to the contacts report done in
104 & 201. I want it to list a primary member�s name and their
information and then also list all the family members related to them
via a relationship.
A: It's perfectly fine if you
have duplicate names between two related tables. What you're going to
end up with is PrimaryT.FirstName and FamilyT.FirstName in
the same query, form, or report. This will work OK. A better method,
however, might be to just use one table and relate it to itself. You can
specify which family member is the Primary person (head of household)
for example, and then make a query to show just the primaries. Then,
relate the table to itself to create a query of primaries and the rest
of the family members.
This technique could also be used for geneaology databases where
each person is in a PersonT table, and each person has a MotherID and
FatherID, and these are just links back to a PersonT record.
I know this might seem confusing, but it's real simple.
See this Free Video Tutorial for step-by-step instructions:
If you've finished through Access
201, that's a great head start. I cover a LOT more with Access
Queries in the upcoming classes... especially in
Access 220 through
223 where I cover lots of
advanced query techniques,
action queries, and much more.
By Richard Rost
Click here to sign up for more FREE tips
|