0
votes

I want to know how Crystal Reports reference the rows in the details section. I used three formula reset formula:

Whileprintingrecords;
shared Numbervar rowvalue1 := 0;
shared Numbervar rowvalue2 := 0;

Calculation formula

Whileprintingrecords;
IF recordnumber=1 then shared Numbervar rowvalue1:=rowvalue1+{table.total};
IF recordnumber=2 then shared Numbervar rowvalue2:=rowvalue2+{table.total};

display formula

Whileprintingrecords;
Numbervar rowvalue3:=(shared numbervar rowvalue2)-(shared numbervar rowvalue1);

I have only two groups and 4 rows in my report I place

reset formula in group header
calculation formula in group details section
display formula in group footer 

and the result was: enter image description here

in the second group the result of substraction was 0 why? is crystal report work like that enter image description here OR enter image description here

1
Is your report grouped? What do you mean by select? Do you mean you only what the output to show row 1 and 44 or do you mean you need to select them for some calculation purpose?CoSpringsGuy
yes my report is grouped and I want to select them for some calculation proposedba2015
Try manipulating using record number fieldSiva
@Siva can you explain me how ?dba2015
Don't write answers.. if you have something then edit your question.Siva

1 Answers

2
votes

try like this:

NumberVar a;
NumberVar b;

    if recordnumber=1
    then a:=Databasefield;

    if recordnumber=44
    then b:=databasefield;

 Edit...............................

In group header create formula @reset

Shared Numbervar count:=0;

Now in detail write formula @count

Shared numbervar count;
count:=count+1;

Now write your created formula

The Reset Formula:

The following formula is to be place in your group header so it will reset the variable on the change of each new group.

Whileprintingrecords;
Numbervar rowvalue1 := 0
Numbervar rowvalue2 := 0

The Calculation Formula:

I will Place this formula in the detail section. Whileprintingrecords; Shared numbervar count;

IF  count=1 then Numbervar rowvalue1:=rowvalue1+{column1}
IF count =2 then Numbervar rowvalue2:=rowvalue2+{column1}

The Display Formula

I will Place this formula in the group footer to display the result

Whileprintingrecords;
Numbervar rowvalue3=rowvalue2-rowvalue1;