Results 1 to 5 of 5
  1. #1
    scor1pion is offline Novice
    Windows 10 Access 2016
    Join Date
    Jun 2016
    Posts
    22

    Question Query to find like members and groups that are members of another group

    Looking for help writing a query that will find the following.
    Querying one table and 2 fields
    Fields: Group and User ID
    The follow member SHIVAK (User ID) is in this Group EDI0090
    Click image for larger version. 

Name:	EDI0090.jpg 
Views:	17 
Size:	4.1 KB 
ID:	43784

    This group EDIPGM, has both the group EDI0090 and SHIVAK in it
    Click image for larger version. 

Name:	EDIPGM.jpg 
Views:	17 
Size:	6.3 KB 
ID:	43785



    Trying to write a query that will find those type of entries. Where both the Group and a member of the group are both members of another group.

  2. #2
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,426
    this looks like it requires a recursive solution which in access can only be done in vba

    it can be done in sql if the depth of the relationships is known. So if the depth is only 2 per your example then join the table to itself on Group=UserID. Perhaps something like this air code

    Code:
    SELECT A.Group, B.UserID
    FROM myTable A INNER JOIN myTable B ON A.Group=B.UserID
    WHERE A.UserID=B.UserID

  3. #3
    Join Date
    Apr 2017
    Posts
    1,679
    This looks suspiciously like domain groups and domain users. When this is the case, or when this is something similar, then there may be cases where:
    You have Group1 with User1 in it;
    Then you have Group2 with Group1 in it;
    ...
    Then you have Group(N) with Group(N-1) in it, and User1 in it, where N may be any number.

    So you must find all groups which have User1 directly in it, and then you have to check all such groups for being members of group chain described above, i.e. for every group not Group(N) you have to try to build such chain, and when you can do this, then for this user this group is subgroup of Group(N).

    And there is no way you can do this as Access query - Access doesn't support truly recursive queries! The only way to do this will be a VBA procedure.

    Maybe there is a way to store results into created empty recordset, and then to return this recordset somehow - but I'm not sure this is possible.

  4. #4
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,927
    Could it be done in s sub query where the subquery A.ID in (select UserID where Group not in A.Group) ?
    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
    scor1pion is offline Novice
    Windows 10 Access 2016
    Join Date
    Jun 2016
    Posts
    22
    Thank you all for your replies. As of now I no longer need this query. Turns out the data I was given was inaccurate. That being said, I am also waiting for more data to come in and I may still need to find a way to perform this search. Will cross that bridge if/when I get there.

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

Similar Threads

  1. Are you coming / RSPV / members
    By SimplyBrass in forum Access
    Replies: 1
    Last Post: 03-17-2018, 11:02 AM
  2. search and edit members
    By Mohammadsharif in forum Access
    Replies: 3
    Last Post: 04-08-2015, 07:36 AM
  3. Replies: 24
    Last Post: 02-04-2014, 07:26 PM
  4. automatically update club members age group
    By sirnickettynox in forum Programming
    Replies: 4
    Last Post: 04-06-2011, 06:52 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