Hi,
I am kinda new to crystal formulas and want to create a report in the following fashion:
UNAIDS 10 10 (MEANS UNAIDS gave 10 items. the second 10 is always the same as the first 10 for the first record and is balance)
ER 5 5 (Means ER took 5 items then 5 items remain)
SD 2 3 (then SD took 2 of the items so 3 items remain)
WHO 5 8 (WHO gave 5 items and balance became 8 cos there were 3 items left from the 10 given by UNAIDS)
....
The process continues. My final approach to the formula was: to save items taken in a batch (i.e. under one tree. i saved them in another forumula and it works great.)
My problem is i can't access the remaining of a batch then add them to the next. in that case 3 + 5. I tried global and shared variables but the result is always that of a batch:
here are my codes for both, first one is named totalTaken and is used in the balance function below it.
Code:SHARED numberVar totalTaken; WhilePrintingRecords; ToNumber({DSSMP_RPT_StockItem;1.originaltotal}+Sum ({DSSMP_RPT_StockItem;1.totaltaken}));
and the problematic code:
Code:SHARED numberVar looper=0; SHARED numberVar totalTaken; SHARED numberVar pretotalTaken; SHARED numberVar activein; --which donation we r in? GLOBAL numberVar prein=0; SHARED stringVar k; WhilePrintingRecords; if recordnumber=1 then ( activein:={DSSMP_RPT_StockItem;1.incominginvoiceid}; prein:=0; totalTaken:={@totalTaken}; ToText({DSSMP_RPT_StockItem;1.originaltotal}); ) else ( if prein<>activein then ( prein:=activein; ToText({@totalTaken} - {DSSMP_RPT_StockItem;1.originaltotal}); ) else ( toText('holy'); ); ) //if prein=0 then //( //ToText('zero'); //) //else ( //ToText(32); // // //); // //prein:=prein+1;


Reply With Quote