Results 1 to 5 of 5
  1. #1
    Dmcleod is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Jan 2013
    Posts
    3

    Need to create a hierarchy of direct and indirect reports


    I created two queries. First one takes every EMP ID and every Manager ID. Second uses the Manager ID from QRY1 and links to EMP ID from the original table to pull in that managers manager ID. In testing the data I am looking at Manager 10592. In QRY1 that manager has 6 reports. I need to be able to keep creating queries so I end up with a list of managers from the WAR table and every emp that reports up to that manager, whether direct or indirect (someone reporting to a manager that reports to another manager up to the complete list of managers from the WAR table)

    I am not getting the results I thought I should. Any ideas?
    Attached Files Attached Files

  2. #2
    recyan's Avatar
    recyan is offline Expert
    Windows 2K Access 2000
    Join Date
    Dec 2011
    Posts
    662
    Not sure if below is what you are looking for, all the same just check it out :

    http://msdn.microsoft.com/en-us/libr...ffice.10).aspx

    Thanks

  3. #3
    Dmcleod is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Jan 2013
    Posts
    3

    Almost ...

    Quote Originally Posted by recyan View Post
    Not sure if below is what you are looking for, all the same just check it out :

    http://msdn.microsoft.com/en-us/libr...ffice.10).aspx

    Thanks
    That works for single levels of management. If a Sr Manager has 2 mgr reports, the 2 mgr reports each have 5 supervisor reports who in turn have multiple non-management reports, then I need a list of all the reports under that 1st Sr Manager, no matter who the direct report is ...

  4. #4
    Dmcleod is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Jan 2013
    Posts
    3
    Quote Originally Posted by Dmcleod View Post
    That works for single levels of management. If a Sr Manager has 2 mgr reports, the 2 mgr reports each have 5 supervisor reports who in turn have multiple non-management reports, then I need a list of all the reports under that 1st Sr Manager, no matter who the direct report is ...
    Name Code MGR
    Sandeep 10 Katherine
    Robert 20 Sandeep
    Marica 30 Robert
    Katherine 40
    Gabriele 50 Sandeep
    Victor 60 Katherine



    I need a report so I can pull the managers name and get the following results:
    Sandeep over Robert, Marcia and Gabreiele.
    Robert over only Marica
    Katherine over Sandeep, Robert, Marcia, Gabriel and Victor

  5. #5
    recyan's Avatar
    recyan is offline Expert
    Windows 2K Access 2000
    Join Date
    Dec 2011
    Posts
    662
    Till someone comes along, Not much in to reports & for that matter, vba, just check if below is of some help :

    Code:
    Public Function GetReportees_1()
        
    Dim dbs As Database
        Set dbs 
    CurrentDb
        
        Dim strsqla 
    As String
        Dim rsta 
    As DAO.Recordset
        
        strsqla 
    "SELECT EmpName, Mgr FROM tblEmpMgrs WHERE (((Mgr) Is Null))"
         
        
    Set rsta dbs.OpenRecordset(strsqladbOpenDynaset)
        Do While 
    Not rsta.EOF
            managerb 
    rsta![EmpName]
            
    Debug.Print managerb
            GetReportees 
    (managerb)
            
    rsta.MoveNext
        Loop
    End 
    Function

    Public Function 
    GetReportees(Manager As String)
        
    Dim strsql As String
        Dim rst 
    As DAO.Recordset
        Dim ManagerD 
    As String
        
        Dim dbsa 
    As Database
        Set dbsa 
    CurrentDb
        
        ManagerD 
    Manager
     
        strsql 
    "select EmpName from tblEmpMgrs where [Mgr] = '" ManagerD "'"
     
        
    Set rst dbsa.OpenRecordset(strsqldbOpenDynaset)
        Do While 
    Not rst.EOF
            
    If (rst.EOFThen
                Debug
    .Print "End of Records"
            
    Else
                
    managera rst![EmpName]
        
                
    Debug.Print " - " managera
                GetReportees 
    (managera)
            
    End If
            
    rst.MoveNext
        Loop
    End 
    Function 
    Thanks

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

Similar Threads

  1. Using a hierarchy table
    By younggunnaz69 in forum Queries
    Replies: 3
    Last Post: 07-18-2012, 10:11 PM
  2. Hierarchy summing
    By dskysmine in forum Queries
    Replies: 17
    Last Post: 06-19-2012, 04:08 AM
  3. product hierarchy
    By Lata in forum Access
    Replies: 13
    Last Post: 08-03-2011, 02:56 AM
  4. [Resolved] Direct Link to Access Form?
    By objNoob in forum Forms
    Replies: 1
    Last Post: 03-16-2010, 12:06 PM
  5. how to play mp3 direct from database
    By sean in forum Access
    Replies: 0
    Last Post: 10-20-2009, 08:27 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