Teri said:
I have a table called Contacts. I have another table called Insurance. I
want to show in a query which Contacts have a particular insurance. If I
query the Contacts table ONLY, I get all the records. If I add the Insurance
table to the query, I get nothing. I'm sure it has something to do with the
relationship, but I can't figure it out.
Can someone PLEASE help?
Teri,
How are the two tables related?
Let's say that table Contacts has a Primary Key (PK) field named ContactID.
And table Insurance has a PK named InsuranceID.
To relate the two tables, you need a field common to both tables. So in table
Insurance, we add a field to store the value of table Contacts PK. Let's call
it ContactId_FK. This is called a foreign key (FK).
If you have a contact "Buggs Bunny" and he has 3 types of insurance - Life,
Auto and HO, then there will be 3 records in table insurance.
table
Contacts ContactID L_Name F_Name
--------- 1 Bunny Buggs
table
Insurance InsuranceID ContactID_FK InsurType
--------- 1 1 Auto
2 1 Life
3 1 HO
In your query, add tables Contacts and Insurance. Drag ContactID from table
contacts to ContactID_FK in table Insurance. This links the two tables.
From table Contacts, add ContactID, F_Name and L_Name to the design grid. From
table Insurance, add InsuranceID and InsurType to the design grid.
Run the query (Click on the red "!" in the toolbar). You should see 3 lines:
ContactID F_Name L_Name InsuranceID InsurType
1 Buggs Bunny 1 Auto
1 Buggs Bunny 2 Life
1 Buggs Bunny 3 HO
HTH