Can you give me an example of the query?
Kofi
Main Topics
Browse All TopicsHello!
I have a database with several related tables:
Contacts table with one record per contact
Relationships table with several records per contact – one record for each relationship a contact has to an organization (multiple contacts, multiple organizations)
Organizations table with one record per organization
The three tables are joined on id numbers. The contacts table is joined to the relationships table; the relationships table is joined to the organizations table.
I am trying to build a report and a data entry form that will have, grouped by organization, a list of the contacts related to it (from the contacts table), and the details of their relationships (from the relationships table). I have been trying to use subreports and subforms to do this, but while I can do one tier of subreports (i.e. main report based on organizations table, subreport based on contacts table), I am unable to reach through to a second table to include data from the relationships table as well.
I thought I might be able to do this by basing the report/form on a query, but when I put fields from more than one table in a query, the query either returns no data, or only records for which there is data in all the involved tables. (Not all records in one table will always have related records in all the others).
Any ideas would be most appreciated.
Kofi
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Kdankwah
It appears from your comment above that the issue with your query is your joins. In this case, you want outer joins, because it sounds like you can have an organization with no contacts, or a contact with not relationship information (and I agree with jadedata, you should use a different name.
For example, after joining the organization table to the contact table in your query, double click on the line that runs between the tables and the join properties window will display. Choose the option that says "Include all of the records from the Organization table and only those records from the Contact table where the join fields are equal" Do the same for the join from the Contact table and the relationship table, choosing to include all of the records from the contacts table.
That should get your query working. Then it is a matter of setting up grouping on your report to properly format the Org., Cont. and Relationships
Contacts <-- Main form, just enter table name in the record source.
---------
The subform needs to have a quey, copy and past following SQL to the record source of your subform (that is after checking table names and field names.
Note: if it is not too late change Contacts to tblContacts or tContacts for ease of use (do the same with your other tables). For queries use qryTotal or qTotal.
Your table structure looks good.
Assumption: tblContacts has ContactID(autonumber), ContactFname....
tblContOrgan (you have called this tblRelationship) has Contact_ID and Org_ID both numb/Long
and tblOrganization hase OrgID (autonumber), OrgFname....
Subreport SQL:
Select tblContOrgan.Contact_ID, tblContOrgan.Org_ID From tblContOrgan Inner Join tblOrganization On tblContOrgan.Org_ID = tblOrganization.OrgID
The parent/child linke is OrgID/Org_ID
After taking care of edit form, we can handle report question later on (possibly as a new question).
Mike
I can not send you the documenter. You have one built into your copy of Access.
You need to select from the menu Tools/Relationships and Access has a layout much like building query relationship, as they are in fact the same thing.
select two of your tables
From one common field in the primary table
left click and hold on a field in the table
drag that field to the other table, dropping it on the field that forms the relationship
you now have created a relationship
the Relationship Builder will also give you some additional options which are best hunted up in Access Help, or else I would just have to copy those sections onto this forum and that would be extremely bad form.
thats not what you said the last time...
Feel free to send it to me, but if other Experts request a copy to assist you, you must provide them a copy as well.
This is my requirement in keepin the the spirit of the EE Membership Agreement.
Do you agree to the above?
If you agree then my email address is found in my profile.
A way to handle this could be
Table: tOrgs tPositions tContacts
Fields: tOrg.OrgID --> tPositions.OrgID
tPositions.PosID
tPositions.ContactID --> tContacts.ContactID
"HOW" the contact is related to an org is in the tPosition Table.
The tPositions table serves to describe the relationship, and link the many to many
The primary keys on these:
tOrgs: (PK) OrgID
tPositions: (PK) OrgID, PosID
(FK) ContactID
tContacts: (PK) ContactID
Business Accounts
Answer for Membership
by: jadedataPosted on 2004-01-29 at 13:49:28ID: 10229944
Greetings Kdankwah!
Yes, you absolutely want a query to drive this report.
Two, you should slightly modify the name of the table "relationships" as this is a reserved word in Access for the Relationships collection of the Database.
Use the Master/Child links on the subrepost to list the data from relationships table, link them by the ID fields you mentioned.
As each detail record is printed the cooresponding relations will be reported in the subreport.
regards
Jack