PParuman
asked on
Trouble with logic around recurring document collections
Hi all
I am trying to build an org chart using document collections. currently , I get the CEO of the company & the build a document collection of all the people who are under Him/Her . Then I call the function again to complie the collection under that person & so on & so on....
My problem is that I can build the structure fine for the first person under the CEO but I cannot go back up the strucure to get to the next person ...
CEO
Person 1
Person 1.1
Person 1.2
Person 1.2.1
Person 1.3
Person 2
Person 3
in my sub routine , I can get the following structure :
CEO
Person 1
Person 1.1
then I am stuck cos I have lost my previous collections .... any ideas
Here is the code that I currently have :
Sub GetEmployees(ID As String)
Set EmployeeCollection = View.GetAllDocumentsByKey( ID)
If EmployeeCollection.Count = 0 Then
PrintTabs(CurrentTab)
Print "No Underlying Employees" + " <br>"
CurrentTab = currentTab - 5
Else
Set EmployeeDoc = employeeCollection.GetFirs tDocument
While Not EmployeeDoc Is Nothing
CurrentTab = CurrentTab + 5
PrintTabs(CurrentTab)
Print EmployeeDoc.FirstName(0) + " " + employeeDoc.LastName(0) + " <br>"
Call GetEmployees(EmployeeDoc.P ersonID(0) )
Set employeeDoc = EmployeeCollection.GetNext Document(E mployeeDoc )
Wend
End If
End Sub
I am trying to build an org chart using document collections. currently , I get the CEO of the company & the build a document collection of all the people who are under Him/Her . Then I call the function again to complie the collection under that person & so on & so on....
My problem is that I can build the structure fine for the first person under the CEO but I cannot go back up the strucure to get to the next person ...
CEO
Person 1
Person 1.1
Person 1.2
Person 1.2.1
Person 1.3
Person 2
Person 3
in my sub routine , I can get the following structure :
CEO
Person 1
Person 1.1
then I am stuck cos I have lost my previous collections .... any ideas
Here is the code that I currently have :
Sub GetEmployees(ID As String)
Set EmployeeCollection = View.GetAllDocumentsByKey(
If EmployeeCollection.Count = 0 Then
PrintTabs(CurrentTab)
Print "No Underlying Employees" + " <br>"
CurrentTab = currentTab - 5
Else
Set EmployeeDoc = employeeCollection.GetFirs
While Not EmployeeDoc Is Nothing
CurrentTab = CurrentTab + 5
PrintTabs(CurrentTab)
Print EmployeeDoc.FirstName(0) + " " + employeeDoc.LastName(0) + " <br>"
Call GetEmployees(EmployeeDoc.P
Set employeeDoc = EmployeeCollection.GetNext
Wend
End If
End Sub
ASKER
ooh Thanks .... sorry , wrong terminology :)
Mind is messed up with other things...
Do you have any idea how to overcome this problem ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
THere is a top level document. It is a Main document.
And there are some level 2 documents. They are responses to top level document. They are response documents.
And there are some level 3 documents. They are responses to level 2 document. They are response to response documents.
And so on...
The key lies in the fact that, you can easily write a routine that recursively drills-down the child document collection given its Unique Note ID. The routine will not only list the current level document but also recursively go down traversing down to the lowest level document in the hierarchy. They prototype of such a routine could be:
Sub ListChildren (strParentDocID as string)
Are you comfortable with the concept?
And there are some level 2 documents. They are responses to top level document. They are response documents.
And there are some level 3 documents. They are responses to level 2 document. They are response to response documents.
And so on...
The key lies in the fact that, you can easily write a routine that recursively drills-down the child document collection given its Unique Note ID. The routine will not only list the current level document but also recursively go down traversing down to the lowest level document in the hierarchy. They prototype of such a routine could be:
Sub ListChildren (strParentDocID as string)
Are you comfortable with the concept?
RECURSE.