Crystal Reports Formula Variable not reset to 0 in Group - crystal-reports

I am creating a report...
Its a kind of Ledger Report..
I am displaying the report Groupwise by Name.
See the below image displaying the error...
Now see the red marking in the image...
I created the formula shown below..
d_ClosBal
WhilePrintingRecords;
NumberVar ClosBal1;
ClosBal1 := 0;
ClosBal1 := Sum({#DebitAmt}) - Sum({#CreditAmt});
IF ClosBal1 > 0 then ClosBal1 else 0;
c_ClosBal
WhilePrintingRecords;
NumberVar ClosBal1;
ClosBal1 := 0;
ClosBal1 := Sum({#DebitAmt}) - Sum({#CreditAmt});
IF ClosBal1 < 0 then ClosBal1 else 0;
And Placed formula in the yellow mark shown in the figure below...
The Sum({#DebitAmt}) is 5740.00 and Sum({#CreditAmt}) = 800.00 shown in figure
The blue marked are the Transactions, ex 1000.00, 945.00, etc....
I even tried putting a formula reseting the value of ClosBal1 to 0 inside GroupHeader but ain't helped.
Suggest me any solutions..

you need to indicate your group levels in this statement otherwise you are just grouping the entire report.
ClosBal1 := Sum({#DebitAmt}) - Sum({#CreditAmt});
example
ClosBal1 := Sum({#DebitAmt},{companyname}) - Sum({#CreditAmt},{companyname});

Related

How to Print specific row in each page Crystal Report

whileprintingrecords;
global numbervar DetailCount;
DetailCount := DetailCount + 1;
Global numbervar DetailCount;
DetailCount Mod 10 = 0
IF Remainder (RecordNumber, 8) = 0 THEN
TRUE
ELSE
FALSE
IF Remainder (RecordNumber, 8) = 0 and not OnLastRecord THEN
TRUE
ELSE
FALSE
i have try this codes but not get it.
Please describe better what you would like to print on each page.
I'm guessing you would like to print a summary that would only show the sum of one printed page.
You need 3 formulas:
sum_pagesum (should be placed in the details-section as hidden field):
whileprintingrecords;
numbervar pagesum;
pagesum:= pagesum + {WHATEVER};
current_pagesum (should be placed in the page-footer-section, this prints your sum):
whileprintingrecords;
numbervar pagesum;
pagesum;
reset_pagesum (should be placed in the page-footer-section after the current_pagesum)
whileprintingrecords;
numbervar pagesum;
pagesum:= 0;

Crystal Reports Prevent global variables from resetting on new page

Is there any way to prevent the resetting of variables on a new page?
In GH2 I initialize the following variable:
WhilePrintingRecords;
Global NumberVar RCountDaysInDenominator := 0;
In GF3:
EvaluateAfter ({#IsEndExamPopulated});
if {#IsEndExamPopulated} = True
then
NumberVar RCountDaysInDenominator := NumberVar RCountDaysInDenominator + 1
else
NumberVar RCountDaysInDenominator := NumberVar RCountDaysInDenominator + 0;
I didn't realize that when a single GF3 spans many pages, these variables reset.
Any suggestions? Thanks in advance!

Why the report errors out when evaluating a formula that equals zero?

I have this formula field:
global numbervar TotDiff;
WhilePrintingRecords;
if {#QuantExceding} <> 0 then
TotDiff := TotDiff + ABS({#QuantExceding})
else
TotDiff := TotDiff
Initially, the if clause was not there, so I thought it was ABS erroring out when passed 0. Then I see that whatever I do with QuantExceding, when it equals 0, the reports errors out and highlights the first line of the if or whatever the line that invokes QuantExceding
Any ideas ?
change formula like this and make sure the {#QuantExceding} is evaluating first:
WhilePrintingRecords;
EvaluateAfter({#QuantExceding});
global numbervar TotDiff;
if {#QuantExceding} <> 0 then
TotDiff := TotDiff + ABS({#QuantExceding})
else
TotDiff := TotDiff

crystal report: print missing records

i want to print missing records in crystal report .
i am using below formula in the report and i have placed this formula in details b section.
details a has normal report fields.
formula:
local numbervar firstemp; // first Emp#
local numbervar nextemp; // next Emp#
local numbervar diff; // difference between firstemp and nextemp
local numbervar increase; // increment for missing Emp#'s
local numbervar result;
increase := 0;
firstemp := tonumber({getRptSalesSummery;1.Bill_Id});
nextemp := tonumber(next({getRptSalesSummery;1.Bill_Id}));
nextemp := nextemp -1;
diff := nextemp - firstemp;
if nextemp = firstemp
then ""
else (
while diff >= 1
do (
diff := diff - 1;
increase := increase + 1;
result := firstemp + increase;
exit while;
);
totext (result,"0000") & chr(13);
)
this formula is not giving me range.
for example if in report there is range of 1 to 10 and 6,7,8,9 is missing records, then if i check in the report its printing 1 to 5 and 6 as missing then directly 10, but its not giving me 7,8,9.
basically i required range of missing records

crystal reports : character "." in domain string errors

My goal is the discern whether the domain has a subdomain or not by counting the number of periods there are in the domain name. If it has 2 periods, there is obviously a subdomain.
I have the following crystal reports formula written in crystal syntax
local numbervar count :=0;
Local numbervar strLen := length({?domain});
local stringvar c := {?domain};
local numbervar i;
local numbervar pos2 :=0;
for i:=1 to strLen do
( if Mid({?domain}, i, 1) = "." then
(
count := count + 1;
if count = 2 then (
pos2 := i
);
);
);
if count > 1 then
left({?domain}, pos2)
else
left({?domain},instr({?domain}, ".")-1)
any ideas? hopefully this is something my tired eyes are just glazing over.
UPDATE: here is the weird thing that happens.
If I add "+ totext(pos2)
if count > 1 then
left({?domain}, pos2) + totext(pos2)
else
left({?domain},instr({?domain}, ".")-1)
it outputs correctly subdomain.domain with the .com removed
if i run it without the totext(pos2)
if count > 1 then
left({?domain}, pos2)
else
left({?domain},instr({?domain}, ".")-1)
it only shows the subdomain part of subdomain.domain.com
Any ideas why?
Should there be a final ; on the last line?
Alternatively, have you considered making the entire formula something like:
Left({?domain},InStrRev({?domain}, ".")-1)