Solved

One to many to many relationship in form

Posted on 2014-03-06
8
339 Views
Last Modified: 2014-03-19
I have a one to many to many relationship that I need to to represent in a form. I thought I could just place sub forms linked but Access will not allow the many to many form. How do I work around this ? Is this a time for de-normalization?

More specifics. I have a customer table. Each customer can have none -one - many pets. Each pet can have none -one - many Grooming visits. I would like to show all the information on one form. Will this require two forms instead?
0
Comment
Question by:PetGuy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
8 Comments
 
LVL 36

Expert Comment

by:PatHartman
ID: 39909788
I would do it with a main form and two subforms.  The "left side" subform will be a list of the pets.  The "right side" subform will be a list of the visits sorted in descending order so the most recent visit is on top.  When you click on a pet in the left subform, the "right" subform will refresh.  When you set the master/child links, the "left" subform is connected to the main form and the "right" subform is connected to the "left" subform so you must include the name of the subform in the master link (sfrmPets.PetID).  I haven't set one of these up recently and don't have a sample handy but you might have to add a requery to the click event of the "left" subform.

Me.sfrmVisits.Requery

If most clients have only a single pet, this will be overkill so in that case, I might use a single subform that is bound to a query that joins the two tables.  The downside to this is that you cannot suppress the PetName because that identifies the pet the visit is for and so it will repeat on every row.  

In a combined subform, you need to decide if the major sort will be date (always descending) or petName.  Once the list gets long, you will probably find that date works better.
0
 

Author Comment

by:PetGuy
ID: 39910093
I have a key of customer code in the Customer (Top or Master) Table. I have a foreign key that links the pet (left) table to the customer table and that works great.  The pet table has a key of PetID. The Groom (right subform) Has a key of GroomID and a foreign key of PetID to link to the pet table but does not have a foreign key to link to the customer table directly. Do I need to add that foreign key to link it to Customer?
0
 

Author Comment

by:PetGuy
ID: 39910181
When I connect groom to pet with Pet.PetID as master and Groom.PetID as subform I get forms asking for Parameter Value for Pet.PetID and Groom.PetID. If I enter blanks for both parameters the form opens but the groom table subform is not linked.
0
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 
LVL 36

Expert Comment

by:PatHartman
ID: 39910558
You don't need the FK to the top table in the Groom table.  It only has to link to the Pet table.

Are you certain the Groom and Pet are the names of your subform controls?  They may be the names of the actual subform objects but what we need here is the name of the subform control.  Click on the edge of the subform to select it and look at the Name property in the properties list.
0
 
LVL 30

Expert Comment

by:hnasr
ID: 39910566
Upload a sample database including the 3 tables with few records in each.
0
 

Author Comment

by:PetGuy
ID: 39917090
Here is a copy of what I am trying to do.
0
 

Author Comment

by:PetGuy
ID: 39917094
I guess I didn't get file attached
groom.mdb
0
 
LVL 30

Accepted Solution

by:
hnasr earned 500 total points
ID: 39917184
Check customer, pet, and groom forms and give feedback. Depict the required output.
Use compact and repair before uploading.
groom-2.mdb
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

749 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