Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: totaling shared variables Post Reply Post New Topic
Author Message
GregD
Newbie
Newbie
Avatar

Joined: 31 Aug 2011
Location: Canada
Online Status: Offline
Posts: 5
Quote GregD Replybullet Topic: totaling shared variables
     Posted: 16 Mar 2012 at 7:10am
Hi,
 
I'm trying to create totals on some data that i have drawn from a subreport.   The data is a list of employees and their tax cost being grouped by an object code (i.e. 51722).  Now i've had no problem pulling the data out of the subreport, but when i try to summarize the data on the main report, the data will not total properly when ever the data continues onto a new page.  When the data is all on the same page, it totals fine.
 
For Example:  Bottom of page 1 shows:
          Employee                  Taxes
51722 Miner:
          Robert                         500 (-->Placed variable VTaxesAN8)
          Pat                             1000
 
Then the data continues onto page 2:
          Matt                             800
          Michael                         900
Total for 51722 Miner       1700 (-->Placed variable VtaxesOBJ)
 
The total for the object 51722 should be 3200, not 1700.  The total only adds what was printed on page 2 and ignores what was on page 1. 
 
Anyone have any ideas?
 
My subreport formula for the shared variable is:
WhilePrintingRecords;
Shared numberVar VTaxesAN8;
VTaxesAN8 := VTaxesAN8+Sum ({@Employer Taxes}, {F0618.YTAN8})
 
On The Main report formula for displaying the taxes by person is:
WhilePrintingRecords;
Shared numberVar VTaxesAN8;
VTaxesAN8
 
Formula On The Main report formula for Totaling the taxes by Object 51722 is:
WhilePrintingRecords;
Shared numberVar VTaxesOBJ;
VTaxesOBJ :=VTaxesOBJ+{@Place Variable - TaxesAN8}
 
 
 
IP IP Logged
GregD
Newbie
Newbie
Avatar

Joined: 31 Aug 2011
Location: Canada
Online Status: Offline
Posts: 5
Quote GregD Replybullet Posted: 16 Mar 2012 at 10:12am
I was stuck on this problem for over a day and a few hours after i posted my topic, i figured out what happening and how to fix it.
 
Apparently each time crystal hits a new page, the report scans through all the groups again and was resetting my variables each time when it reads my formula to reset them to zero.  I solved this by adding "Not inrepeatedgroup header" to my fomula to tell it when to reset my variables as follows:
 
if not inrepeatedgroupheader then
(WhilePrintingRecords;
Shared numberVar VTaxesOBJ;
VTaxesOBJ := 0;)
 
So this tells crystall if the group header is not being repeated when it hit a new page, to then reset my variable to zero.
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum