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!

Variable value calculated twice for last detail line.

Status
Not open for further replies.

JZajda

Technical User
Jan 15, 2002
32
US
I have a formula which sets variables based on the date. My problem is for some of the variables the value is getting updated twice for the last record in the group. It only seems to happen with the Month variables, the Fiscal Year ones have the correct value.

Details on the formulas and report setup are below. Any suggestions would be greatly appreciated. I am using Crystal 8.5 against a SQL Server 2000 db.

Thanks,
Joy


The report is grouped by product code.

Group Header: Reset Function

Detail Section (Suppressed)
WhilePrintingRecords;
numberVar JulyQuantity; numberVar AugQuantity;numberVar SeptQuantity; numberVar OctQuantity;numberVar NovQuantity;
numberVar DecQuantity;numberVar JanQuantity; numberVar FebQuantity;numberVar MarQuantity; numberVar AprQuantity;
numberVar MayQuantity; numberVar JuneQuantity;numberVar LastFYSales;numberVar LastFYQuantity;numberVar ThisFYQuantity;numberVar ThisFYSales;

If {Activity.TRANSACTION_DATE} >= Date(Year({@Fiscal Year Start}),07,01) and
{Activity.TRANSACTION_DATE} < Date(Year({@Fiscal Year Start}),08,01) then
(JulyQuantity:=JulyQuantity + {Activity.QUANTITY};
ThisFYQuantity:=ThisFYQuantity+{Activity.QUANTITY};
ThisFYSales:= ThisFYSales + tonumber({Activity.AMOUNT})) else

If {Activity.TRANSACTION_DATE} >= Date(Year({@Fiscal Year Start}),08,01) and
{Activity.TRANSACTION_DATE} < Date(Year({@Fiscal Year Start}),09,01) then
(AugQuantity:=AugQuantity;AugQuantity:=AugQuantity + {Activity.QUANTITY};
ThisFYQuantity:=ThisFYQuantity+{Activity.QUANTITY};
ThisFYSales:=ThisFYSales+ tonumber({Activity.AMOUNT})) else

etc...


Group Footer: Formulas to display the calculated quantities

WhilePrintingRecords;
numberVar JulyQuantity;
JulyQuantity

WhilePrintingRecords;
numberVar AugQuantity;
AugQuantity

 
Assuming that you really do have a reset function (nothing posted here), then it looks pretty good.

Group header reset:
WhilePrintingRecords;
numberVar JulyQuantity:=0;
numberVar AugQuantity:=0;
etc...

Here's a problem:

AugQuantity:=AugQuantity;AugQuantity:=AugQuantity + {Activity.QUANTITY};

Probably a pasting error.

Since the yearly totals are using the same method, I would try inserting a Running Toal and use the same criteria in the Evaluate->Use a Formula to verify that you get the same, and also unhide the details and verify whether you're getting a second row at the end of the details.

-k
 
Thanks for the input. The reset function was just what you listed and augustqty was a pasting error. I apologize for that.

I tried the running totals and those work fine. I will just redo the report using those instead. I just can't figure out why there was an issue with the totals using my functions.

I guess it will have to remain a mystery...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top