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

Calculating Running Totals on Shared Variables

Status
Not open for further replies.

ainganni

IS-IT--Management
May 18, 2004
5
GB
Hi, I am using CR 11 and have a sub report which calculates the number of events that have taken place. this number is then set up as a shared numbervar and passed into the main reprot for usage later.
underpinning the database is an organisation structure of four levels 1-4 so the sub report calculates the event for a given level 4 organisaiton, however the level 3 events as a sum of all associationed level 4s and so on. what I want to do is to create a running total of these event resetting them at appropiate time, however when I create a new running total the formaula containg the shared numbervar is not availible!!

does anyone have any ideas or suggestions on how i can over come this!!

thanks in advance,

Andrew
 
Use variables. Create these formulas:

//{@reset1} for the GH#1:
whileprintingrecords;
numbervar sum1 := 0;

//{@reset2} for the GH#2:
whileprintingrecords;
numbervar sum2 := 0;

//{@reset3} for the GH#3:
whileprintingrecords;
numbervar sum3 := 0;

//{@accum} for the GF#4_b (?) section (in a section below the one in which the subreport is executing):

whileprintingrecords;
numbervar sum1;
numbervar sum2;
numbervar sum3;
numbervar grsum;
shared numbervar yourshvar;
sum1 := sum1 + yourshvar;
sum2 := sum2 + yourshvar;
sum3 := sum3 + yourshvar;
grsum := grsum + yourshvar;

Then create four display formulas:

//{@displsum1} to be placed in GF#1:
whileprintingrecords;
numbervar sum1;

//{@displsum2} to be placed in GF#2:
whileprintingrecords;
numbervar sum2;

//{@displsum3} to be placed in GF#3:
whileprintingrecords;
numbervar sum3;

//{@displgrsum} to be placed in the report footer:
whileprintingrecords;
numbervar grsum;

If the subreport can be null, you would also want to have a reset formula for the shared variable in a section above the one in which the subreport is located:

whileprintingrecords;
shared numbervar yourshvar := 0;

-LB
 
thanks for the reply, unfortunalty the structure of my report so far does not allow me to do what you have suggested as the organisation structure is unknown at the runtime of the report. the user will decide what part of the organistion they will use!!

thanks anyway,

regards, Andrew
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top