Jeff, you're making this much harder than it needs to be.
In less time than it takes to explain it, I've built the table as explained
in the last reply and the query:
http://allenbrowne.com/temp/DownlineQueryDesign.PNG
When you run the query, it looks like this:
http://allenbrowne.com/temp/DownlineQueryResult.PNG
All you do is enter the ClientID of the recruiter into the RecruiterID
column. Access automatically populates the Recruiter1, Recruiter2 and
Recruiter3 columns of the *query* for you.
Use the *query* as the RecordSource for any form or report where you need to
show the upline recruiters.
You can easily design a similar query going the opposite way (downline
recruits), but of course the initial client will be repeated many times if
they have multiple recruits.
If it helps, you can paste this into SQL view in a new query:
SELECT Client.*,
[Client_1].[Surname] & ", "+[Client_1].[FirstName] AS Recruiter1,
[Client_2].[Surname] & ", "+[Client_2].[FirstName] AS Recruiter2,
[Client_3].[Surname] & ", "+[Client_3].[FirstName] AS Recruiter3
FROM ((Client LEFT JOIN Client AS Client_1
ON Client.RecruiterID = Client_1.ClientID)
LEFT JOIN Client AS Client_2
ON Client_1.RecruiterID = Client_2.ClientID)
LEFT JOIN Client AS Client_3
ON Client_2.RecruiterID = Client_3.ClientID;
--
Allen Browne - Microsoft MVP. Perth, Western Australia
Reply to group, rather than allenbrowne at mvps dot org.
Jeff @ CI said:
Allen, I configured the query like you directed, however, I am struggling
to
implement the solution.
Problem One - I am trying to implement the list of which client recruited
who until we get to the featured client. On the form, I display contact
info
and other info on said client. I would then need to display (from a
query)
the ClientID and Name (joined into a string) the person who recruited the
current Client, and then the person who recruited the client who recruited
the current client, and finally, the top level person.
Related, I have to also create the report to show the downline.
I am thinking that the best way to do this is to create a seperate table
with four fields. [ClientID], [TierLevel1], [TierLevel2], [TierLevel3].
All are long integer fields and there is no primary key. Tier 1 is the id
of
the client who recruited current client. Tier 2 is the next level up and
so
forth. What I am unclear on is how do I populate this table - if it is
practicle.
The method I am looking at is when I enter a new client into the database,
I
enter only the person who recruited the new client. When I save the data,
it
would launch the process to add the new client to the above table and add
in
the available tiered clients - establish parentage / genealogy if you
will.
This table would then be the basis for a down line report and any other
objects that I will need to provide as management continues to evolve my
little beast.
Thanks in advance for your help and thanks again for the many previous
times
you have helped.
Jeff