Results 1 to 4 of 4
  1. #1
    PSSMargaret is offline Advanced Beginner
    Windows 10 Access 2010 64bit
    Join Date
    Dec 2016
    Posts
    55

    Many-to-Many Relationship -

    I could use some guidance. I have set-up simple many-to-many relationships before but I am in need of a more complex one OR maybe it’s not really a many-to-many relationship but I want to make sure I set-up it correctly from the beginning.

    I have tblContacts and frmContacts and for each Contact I need to add a subform where I can enter the populations that apply to them. Each Contact can have multiple Population Levels with corresponding Population Types and Population Subtypes.

    Contact 1 and Contact 2 may have totally different values than Contact 1.

    Contact Population Level Population Types Population Subtypes
    Contact 1 Federal Business Association HOA
    Contact 1 State Disabled Community Partner



    Contact Population Level Population Types Population Subtypes
    Contact 2 Local Tribal Private Business
    Contact 2 Federal Youth Advisory Council

    I did set-up a test where the junction table includes ContactID and PopulationLevelID and they are both primary keys in the junction table. ContactID is automatically unique and it won’t let me changes it. PopulationLevelID is not unique.

    I also added to the junction table fields for Population Types and Population Subtypes, however, if I add another row to the table for Contact 1 where there is a second Population Level of Federal, I get and error stating.

    “The changes you requested to the table were not successful because they would create duplicate values in the index, primary key, or relationship. Change the data in the field or fields that contain duplicate data, remove the index or redefine the index to permit duplicate entries and try again. “

    I changed both ContactID and PopulationLevelID indexes to Duplicates OK, but I still get the error. I’m doing something wrong or maybe it’s not really a many-to-many relationship?

    If it a many-to-many relationship, can you provide some guidance on how to set it up correctly? Any help is greatly appreciated.

  2. #2
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,118
    Do you mind uploading a small sample file with your tables (no sensitive data, just a couple dummy records to show the issue)?

    Cheers,
    Vlad
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  3. #3
    PSSMargaret is offline Advanced Beginner
    Windows 10 Access 2010 64bit
    Join Date
    Dec 2016
    Posts
    55
    Actually, I think I resolved it. I made all four fields be a Primary Key and it's working. Let me if this is wrong or dangerous in any way. I don't have the time to strip down the database to send to you. I'm working on a deliverable.

    Click image for larger version. 

Name:	Capture.PNG 
Views:	14 
Size:	7.1 KB 
ID:	43913

  4. #4
    orange's Avatar
    orange is online now Moderator
    Windows 10 Access 2016
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,734
    Margaret,

    Please
    -tell us about the application in simple English (an overview of the "business" involved,
    -show us any tables and relationships you have,
    -some sample data - a few more records so we can see what and how these subjects fit together.
    Contact
    Population Level
    Population Types Population Subtypes

    To test your set up you need some sample scenarios and sample data.

    Good luck.
    Last edited by orange; 01-15-2021 at 01:59 PM. Reason: spelling

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Relationship Help (one-to-many, many-to-many?)
    By MelT in forum Database Design
    Replies: 8
    Last Post: 02-09-2018, 10:01 AM
  2. Need help with my relationship.
    By lccrews in forum Access
    Replies: 3
    Last Post: 10-02-2017, 12:05 PM
  3. Replies: 3
    Last Post: 03-19-2015, 05:26 PM
  4. Replies: 1
    Last Post: 12-06-2014, 12:49 PM
  5. Relationship Help?
    By Ritequette in forum Access
    Replies: 3
    Last Post: 10-05-2012, 06:18 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums