Solved

One to many to many relationship in form

Posted on 2014-03-06
8
338 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
  • 4
  • 2
  • 2
8 Comments
 
LVL 35

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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
LVL 35

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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

789 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