Results 1 to 11 of 11
  1. #1
    cgoss is offline Novice
    Windows 11 Access 2016
    Join Date
    May 2024
    Posts
    4

    Linking Single Values from Multiple Combo Boxes with ID Control Source to Single Foreign ID

    I have a many to many relationship database in Access 2016 between books and genres as an example case. The problem I am running into on my Book Form - Genre Subform setup is in trying to use multiple genre combo boxes (let's say 3) that have the genreID control source to have a different selection in each (e.g. combo box 1 select Fiction, combo box 2 select Fantasy, combo box 3 select Romance). Is there a way to have that set up where the genreIDs selected can relate back to a single bookID?



    Also, I have been able to somewhat do this with a multi valued field, but I would really like to avoid using that if at all possible.

    I have attached pictures for some reference.
    Attached Thumbnails Attached Thumbnails Screenshot 2024-05-10 020354.png   Screenshot 2024-05-10 012637.png   Screenshot 2024-05-10 012305.png  

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    5,030
    You would just have multiple records in Book Genre for each genre. just like your second picture?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #3
    cgoss is offline Novice
    Windows 11 Access 2016
    Join Date
    May 2024
    Posts
    4
    Yes, the second picture is somewhat of another solution, but it just looks pretty clunky to me, and it only functions like that if I have it in datasheet view. I wanted to see if I would be able to have a setup like the first picture in form view but where the individual combo boxes can have different selections like the second picture.

  4. #4
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    5,030
    The problem with the first picture is, what if you have 4 genre for a book?
    With the second picture, that is not an issue.
    You could concatenate all the genre into a textbox control so would have "Romance, Fantasy, Fiction", but would still have that structure in picture 2.
    If you need to add a 4th Genre, that would be another record.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  5. #5
    cgoss is offline Novice
    Windows 11 Access 2016
    Join Date
    May 2024
    Posts
    4
    The book-genre database is just an example. The database I am trying to do this in is an estimators-estimate database where - at most- only 3 people collaborate on 1 estimate. So that's why I am not necessarily trying to have potential unlimited quantity of genres - but I do see that you generally would want that if you don't have a constraint on quantity.

  6. #6
    orange's Avatar
    orange is offline Moderator
    Windows 10 Office 365
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,746
    I agree with Welshgasman-- structure something like

    Estimate--->EstimateCollaborator<---People/Collaborators

    You can add logic to constrain the number of collaborators per estimate.

  7. #7
    madpiet is online now Competent Performer
    Windows 10 Office 365
    Join Date
    Feb 2023
    Posts
    174
    Yup. If you wanted to limit the number of collaborating estimators, you'd put code in the BeforeInsert event of EstimateCollaborator to check for the current number of collaborators and reject the insert if you're already at maximum. (or set the AllowAdditions property of the subform to false when the number is reached).

  8. #8
    cgoss is offline Novice
    Windows 11 Access 2016
    Join Date
    May 2024
    Posts
    4
    Well, the main thing isn't the constraint - I agree I could limit that through some code, but the constraint itself isn't needed for this. I am moreso trying to have 3 individual combo boxes that can each choose a different Analyst/Collaborator and update the Junction Table for each. I.e. I would like to be able to use these three combo boxes to add 3 new records relating the respective AnalystIDs to 1 EstimateID in the Junction Table (at least I think that is what I am trying to do). Currently, what I have is in the attached picture.
    Attached Thumbnails Attached Thumbnails Screenshot 2024-05-10 143503.png  

  9. #9
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,530
    Post 8 was moderated, I'm posting to trigger email notifications.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  10. #10
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    5,030
    So cycle through your combos.
    If they have a value use either sql to add a record or a recordset. The choice is up to you.

    Now how you get them back for display the next time will be a little more complicated, though a reverse of the procedure.

    Then you have the issue if you retrieve the three records and decide to amend one of them for a new value. That will add some complication as well.

    I wish you well with your structure.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  11. #11
    madpiet is online now Competent Performer
    Windows 10 Office 365
    Join Date
    Feb 2023
    Posts
    174
    Why not do something sensible like remove the "used" items from the combobox for the given record, so a user can't add the same analyst 3 times? Or just create a unique index on EstimateCollaborator table on (EstimatorID, EstimateID). You're making a really simple thing waaaaay more complicated than it needs to be. Maybe read Allen Browne's articles on indexing in Access.


    • Indexed: To prevent duplicates in a field, set this property to Yes (No Duplicates). Using the Indexes box in table design, you can create a multi-field unique index to the values are unique across a combination of fields.

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

Similar Threads

  1. Replies: 4
    Last Post: 04-26-2020, 02:33 AM
  2. Single Field Combo Box to Add Source Table.
    By raychow22 in forum Forms
    Replies: 4
    Last Post: 09-01-2017, 10:25 AM
  3. Replies: 3
    Last Post: 02-13-2017, 01:33 AM
  4. Single Control Button for multiple Combo Boxes
    By kingofthekassel in forum Programming
    Replies: 5
    Last Post: 08-05-2015, 02:06 PM
  5. Replies: 1
    Last Post: 09-11-2014, 05:53 AM

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