Reputation: 37
i want if x is greater than y then display the x else display nothing. here's my code
numberVar x := sum({LedgerTbl.Debitables}) ;
numberVar y := sum({LedgerTbl.Creditables});
StringVar message := " ";
if x > y then
x
else
message
but what i did always gives me an error "A Number is required here". anyone can help me out thanks in advance :D
Upvotes: 0
Views: 805
Reputation: 26262
You really don't need to use variables to solve this problem.
Instead, try:
// returns a numeric value or a Null
if sum({LedgerTbl.Debitables}) > sum({LedgerTbl.Creditables}) then
sum({LedgerTbl.Debitables})
Upvotes: 2
Reputation: 560
1 - Check your data field type in the db it must be INT. 2- Try ToNumber function as follow :
numberVar x := (sum(ToNumber({LedgerTbl.Debitables})));
Calculation Error in Crystal Report Fomula
Upvotes: 1
Reputation: 9091
you are trying to use one number value
and one string value
hence the error.
USe totext to convert number to string and use as below.
numberVar x := sum({LedgerTbl.Debitables}) ;
numberVar y := sum({LedgerTbl.Creditables});
StringVar message := " ";
if x > y then
ToText(x)
else
message
Upvotes: 0