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 ...

                       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 :

                               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
            Print  "No Underlying Employees" + " <br>"
            CurrentTab = currentTab - 5
            Set EmployeeDoc = employeeCollection.GetFirstDocument
            While Not EmployeeDoc Is Nothing
                  CurrentTab = CurrentTab + 5
                  Print EmployeeDoc.FirstName(0) + " " + employeeDoc.LastName(0) + " <br>"
                  Call GetEmployees(EmployeeDoc.PersonID(0))
                  Set employeeDoc = EmployeeCollection.GetNextDocument(EmployeeDoc)
      End If
End Sub  
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Hey buddy,

PParumanAuthor Commented:

ooh Thanks .... sorry , wrong terminology :)

Mind is messed up with other things...

Do you have any idea how to overcome this problem ?

Define EmployeeCollection as local variable in this sub. Your previos collections will not lost after returning to previos levels and the same level of recursion.

WBR, Alex

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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?
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Lotus IBM

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.