Solved

One to many to many relationship in form

Posted on 2014-03-06
8
341 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 38

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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
LVL 38

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 custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …

696 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