0
votes

How to suppress a Text Object field in Crystal Report based on Header Value. I have 2 text object fields below the Header and I want to suppress one or other based on my header.

I.e. my header is dynamic and it gets different header value.

CASE 1. In certain case if the header is "ABC" then I want to suppress or hide the 1st text object.
CASE 2. If the header is "DEF" then I want to suppress or hide the 2nd text object.

1

1 Answers

0
votes

To suppress just a field and not the entire header:

  1. Right click on the first text object
  2. Select Format Text from the menu
  3. On the Common tab, find the checkbox labeled Suppress. Don't check it though.
  4. Instead, click on the x+2 button on the right side.

    Note: It is quite far away from the Suppress checkbox it belongs to. See screenshot below for help with finding the button.

enter image description here

  1. In the formula box that appears, type your condition for suppressing the text box. For example, if you want to suppress the text field if the header is "ABC" then you may want to enter the following:

    {@HeaderField} = "ABC"
    
    1. Repeat for the next text field.

However, there may be an easier way for you to go about this. Instead of having two text objects, create one formula with an IF-THEN-ELSE statement within to determine which text is displayed.

For example:

If {groupname} = "ABC" then "first set of text"
Else if {groupname} = "DEF" then "second set of text"
Else "Error"

or

If {groupname} = "ABC" then "first set of text"
Else "second set of text"

or

Select {groupname}
Case "ABC": "first set of text"
Case "DEF": "second set of text"
Default: "Error"