Results 1 to 3 of 3
  1. #1
    rogue94 is offline Novice
    Windows 10 Access 2016
    Join Date
    Jul 2017
    Posts
    1

    Combo box and many-to-many relationship

    I am fairly new to MS Access and looking for a solution regarding a form I am trying to build.

    The form should be used to show different user entries in the data base and to create or modify users.


    Actually I am blocking on how to show available countries/servers and the ones which are already assigned to a user via a combo box and a many-to-many relationship.

    To resume:
    I have several tables which combined provide me the information I use to build the form (different access to different systems for a user).

    My first table Users provides me information about first name, last name etc.
    A second table Servers includes the list of different countries/servers a user can have access to.

    Since a user can have access to different servers/countries and a country/server can have different users who are accessing it I am confronted with a many-to-many relationship.
    Therefore I created a junction table which includes the userID as FK (from the User table) and the ID as another FK (from the Servers table).

    What I am trying to achieve now but where I am blocking is:


    • to have a combo box which lists all available servers/countries
    • mark (check) the entries which are linked to the user record which is shown


    example:
    Servers: Belgium, Germany, Netherlands, Sweden, UK
    User: John Doe => access to Germany & UK


    • list/combo box should show all countries but select only the ones John doe has access to (when record John Doe is selected)

    Is there any way to achieve this and what needs to be done ?
    I am also open for any other solution if this cannot be done via a combo box.


    Thanks for the help.

  2. #2
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    When a user is selected on the form, a listbox could show all the servers they currently are connected with. A combobox would then list all servers that the user is NOT connected with and would be used to add new servers to this user.

    Probably an easier way is to have a subform of servers for this user, that will combine both of those and records can be added/deleted as required.

  3. #3
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,928
    Agree, form/subform arrangement may be easiest. Main form bound to Users and subform bound to junction table with a combobox to select server. The RowSource for this combobox could be like:

    SELECT ID, Country FROM Servers WHERE ID NOT IN (SELECT ServerID FROM UserServers WHERE UserID=[UserID]);
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Replies: 7
    Last Post: 12-05-2016, 10:13 AM
  2. Replies: 3
    Last Post: 03-19-2015, 05:26 PM
  3. Replies: 1
    Last Post: 12-06-2014, 12:49 PM
  4. Replies: 10
    Last Post: 03-22-2012, 07:00 PM
  5. Replies: 5
    Last Post: 11-30-2011, 07:02 PM

Tags for this Thread

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