Solved

One to many to many relationship in form

Posted on 2014-03-06
8
334 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 34

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
 
LVL 34

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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
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…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

747 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now