0
votes

I am using crystal report with vb.net and I want to show/hide some field by another field's visibility.Firstly I add suppress condition to one field like=>

if Not OnfirstRecord And ({Field1} = previous({Field1})) then
true

I have added this condition because I don't want to show duplicate field and it works.And then I have added the line to crystal report that line will show only when field1 visible = true.

My idea is to show line when field1 visible and hide when field1 hide.So how can I show the line that condition depends on field1 visibility?

1

1 Answers

1
votes

I'm not aware of a way to check if a field is suppressed or not, but since you are using a formula to suppress the field you wish to test for suppression, you simply need to invert the logic used in that formula.

If Field_A has the following suppression formula:

if Not OnfirstRecord And ({Field1} = previous({Field1})) then
true
else
false

Then Field_B would have this suppression formula:

if Not OnfirstRecord And ({Field1} = previous({Field1})) then
false
else
true

Also, I would like to point out that you don't always need to use If..Then..Else logic in suppression formulas. The expressions you use in an If statement will ultimately evaluate to a true or false value. You can shorten a suppression formula to just the expression itself and the suppression will work the same with less coding for you. :)

Since you used if statements though, I added an else to your logic. A suppression formula that uses an If statement can have unexpected results when you don't specify a condition for both true and false values. When you only return a true value the formula can only suppress the field. Once one record evaluates to true the formula can never set the value back to false if a following record needs to be suppressed. This is another reason why its best to only use expressions in the suppression formula. Since the expression always evaluates to true or false they can help prevent you falling into the logic trap of an if statement that has no else condition specified.