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!

reset the total on change of a group 1

Status
Not open for further replies.

maas

Programmer
Sep 3, 2009
148
BH
Hello All,

I am having a structure of this report:

Group Header 1#: Account No.(different Accounts)

Group Header 2#:Type{Short-Medium} for each account

Details: {@Amount}, {Market_Total}

Group Footer 2#: {@sum_Type}, {@sum_Market_Total}

Group Footer 2#: {@grand_sum_Type}, {@grand_sum_Market_Total}

Now, In my case I tried to use the running totals in my report, but I can't because in the {@Amount}, {Market_Total}, I am using if statements to refer to fields and do some calculations, so I used the technique which was given by lbass:
//{@reset} to be placed in GH#1:
whileprintingrecords;
numbervar sumpct;
if not inrepeatedgroupheader then
sumpct := 0;

//{@accum} to be placed in the detail section (if that's where the percentages are):
whileprintingrecords;
numbervar sumpct := sumpct + {@yourpctformula};
numbervar grtotal := grtotal + {@yourpctformula};

//{@displaygrp} to be placed in the GF#1:
whileprintingrecords;
numbervar sumpct;

//{@displaygt} to be placed in the report footer:
whileprintingrecords;
numbervar grtot;
and it is giving the totals, but it is not reseting when the account number is changing, it is keeping on adding the sum amount.

So, what do you suggest to do in the {@reset formula}
//{@reset} to be placed in GH#1:
whileprintingrecords;
numbervar sumpct;
if not inrepeatedgroupheader then
sumpct := 0;
 
First the variable must be named the same in all places, either "grtotal" or "grtot". The display formula I suggested for the report footer (NOT the group footer) and the name of the variable (short for "grand total") indicated that I was showing you how to create a report level result, not a group result. If you want it to reset, add it to the reset formula (here assuming you name the variable grtotal everywhere):

whileprintingrecords;
numbervar sumpct;
numbervar grtotal;
if not inrepeatedgroupheader then (
sumpct := 0;
grtotal := 0
);

-LB
 
Thank you lbass, by adding this code in my previous code, the reset will be on change of group Header 1#? or I need to do more adjustment?
 
Yes, if that is where you have placed the formula.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top