Sandrous
Sandrous

Reputation: 141

Crystal Report: hide some objects with Format Object - Suppress Formula

I have a report that outputs 4 labels per page.
The data are correctly retrieved from an ArrayList of a class that I have made only for the report and are correctly displayed.
In my class there are also 4 booleans named: Show1, Show2, Show3, Show4, that I'm using for adjust the visibility of 4 Text Objects with a White background, 1 for each label:

if isnull({MyModel.Show1}) then
  false
else
  if {MyModel.Show1} then 
    true 
  else 
    false

The problem is that the report throws an exception, asking me for a Boolean. But these variables are never null, always false and true when necessary. I have put the null-check for avoid problems, but the exception is thrown without the null check too. I have tried to change the type of the variables, using an int instead of a bool and checking the number, returning true or false if 1 or 0: nothing changes, in this case the exception asks me for an integer.

The exception is ErrorKind with the message A boolean is required here or A number is required here in the 2nd case.

I can't understand what is happening...

Any suggestion?

Thanks all

Upvotes: 1

Views: 2612

Answers (1)

Sandrous
Sandrous

Reputation: 141

Ok, I've solved the problem.

I have realized that the formula wants the condition, not the return value. So the correct formula, in Crystal syntax, is:

{MyModel.Show1} = true

If the condition is true, the return will be true, else the return will be false, and all work fine.

Upvotes: 1

Related Questions