views:

764

answers:

3

I have a simple formula in crystal syntax which looks something like this :

if isdate(totext({Absence Details.Return to Work Interview Date})) = true
  and {Absence Details.Return to Work Interview required} = true then
    1
else
    0;

This is the actual code of the formula

but the else part is never getting executed, when the condition is not true report just shows blank. I am not sure what I am doing wrong here.

Thanks in Advance. - Amit

A: 

Edit: NM, code was posted to the comments. Doesn't look like this is the issue.

My guess, assuming you've debugged correctly is that you've got a semicolon somewhere you shouldn't.

if {something} = x then
   do something;
else
   do something different;

instead of

if {something} = x then
   do something
else
   do something different;

This would cause the behaviour, assuming it doesn't choke on the orphaned else clause. But as the comments say, short of posting real code, we can only guess at what's going on. It could be as simple as your evaluation is always true.

patros
A: 

Change the 0 to a 7 and see if it actually prints 7. Some report generation tools (and I have little experience with Crystal but quite a bit with others) will leave fields blank if they're zero - this often helps in reading the report by reducing unnecessary clutter.

If the 7's print out, then that's what the problem is, and it's a matter of figuring out how to get Crystal to output an actual 0.

That may be a matter of configuring the output field or even stting it to a textual "0" instead of numeric 0.

Of course, if that doesn't print out 7's, then feel free to let me know.

paxdiablo
It's not printing 7 either.
Amit
+2  A: 

Maybe you have some null value in your fields - in such case crystal just returns null. You then need either "convert null values to default" setting for report or explicit testing against nulls.

Arvo