Solved

One to many to many relationship in form

Posted on 2014-03-06
8
335 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
Backup Your Microsoft Windows Server®

Backup 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.

 
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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…

863 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

19 Experts available now in Live!

Get 1:1 Help Now