Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Formatting Hierarchical Groups... 1

Status
Not open for further replies.

checkai

Programmer
Jan 17, 2003
1,629
US
I want to format these parent/child groupings...however, if I indent the child, i then have all of the other columns off center, which i don't want....is there a formula function that states if the current record is a child of another record???

thanks,

dlc
 
We published a technique to work with hierarchical group levels in August 2002 (Crystal Clear 28).

You need to use variables to track what level in the hierarchy you are.

A reset formula in the Report Header section
WhilePrintingRecords;
numbervar array levels:=[0,0,0,0,0]; //supports 5 levels
levels[1];

A formula in the Group Header to calculate the group level we are in.

WhilePrintingRecords;
numbervar array levels; // array of hierarchy index
numbervar i; //counter for loop

if isnull({Employee.Supervisor ID}) then
levels[1] := {Employee.Employee ID};
if not isnull({Employee.Supervisor ID}) then
for i:= 1 to count(levels)-1 do (
if {Employee.Supervisor ID} = levels then levels[i + 1] := {Employee.Employee ID});
levels[1]; // don't need to do anything here - but helpful for testing

You now have an array of where you are in the hierarchy, and you can use this for indenting selected columns, or conditionally suppress some levels of the hierarchy.


Editor and Publisher of Crystal Clear
 
I am getting an error with these 2 formulas...I have 4 Groups...I want the hierarcy value to be displayed on gf4 because it is displayed like this...

GH3
GF4

In ReportHeader:
WhilePrintingRecords;
numbervar array levels:=[0,0,0,0,0]; //supports 5 levels
levels[5];

In GH3:
//A formula in the Group Header to calculate the group level we are in.

WhilePrintingRecords;
numbervar array levels; // array of hierarchy index
numbervar i; //counter for loop

if isnull({Star_SPWipAging.parentclientid}) then
levels[1] := {Star_SPWipAging.clientID};
if not isnull({Star_SPWipAging.parentclientid}) then
for i:= 1 to count(levels)-1 do (
if {Star_SPWipAging.parentclientid} = levels then levels[i + 1] := {Star_SPWipAging.clientID});
//levels[1]; // don't need to do anything here - but helpful for testing



any ideas??
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top