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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Totals from subreport wrong when the group spans into multiple pages

Status
Not open for further replies.

raja2008

Technical User
Apr 16, 2008
265
US
Hello Everyone!


I'm using Crystal 2008 and SQL Server 2005



I have 2 groups in the main report

My subreport is in the footer of the group # 2

I calculate the total documents in the subreport and pass it to the main report by using a shared variable.

shared numbervar BarDataCount:=0;
BarDataCount:=Count ({Table.BarData}, {@Proper Bardata});


Shared variable in Main Report
Formula #SharedBarDataCount

shared numbervar BarDataCount;
BarDataCount;

This is placed in one of the footer sections of Group #2 below the Subreport section.


I use this variable to get the totals for the Group 1 # and the Grand Total.

Formula :BardataBUnitCount


shared numbervar BunitBardataCount;
shared numbervar BarDataCount;
shared numbervar GrandBarDataCount;
BUnitBardataCount:=BUnitBardataCount+BarDataCount;
GrandBarDataCount:=GrandBarDataCount+BarDataCount;
BarDataCount:=0;
BunitBardataCount;


I'm reseting the BardataCount here and displaying the BUnitBardataCount value in the Group #1 Footer

I placed BUnitBardataCount reset formula in the Group #1 header

Reset formula
shared numbervar BunitBarDataCount:=0;



Everything works fine

The totals from subreport are coming fine to the main report
and adding up fine for the Group #1 and Grand Totals

Until the value of Group#1 spans into more than 1 page
I mean if there more Group#2's under the Group#1 and they span into the next page

Since the BunitBarDataCount is reseting on the Group#1 header

whatever it adds up in the first page is setting back to '0' and then it is adding the values in the next page and displaying that total.


basically if there are multiple pages i'm getting the totals of only the ones in the last page for that Group#1.


Please help ,I don't know how to handle this.


Hope it is clear
 
You probably have a repeated group header so the reset formula is activated inappropriately. Use formulas like this for resets in group headers:

shared numbervar yourvar;
if not inrepeatedgroupheader then
yourvar :=0;

-LB
 
Hello LB!

Thank you very much.

That is exactly what was happening.

I had the repeat group herdes on each page option checked in the Change group options .

I have a question for you LB

Where can we find all these options that we have in crystal reports.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top