4
votes

I want to achieve the following in a Crystal report, please let me know if they are possible:

  • Hide/Unhide a certain field based on an input parameter
  • Change the content of a certain field in the page header and in the details sections based on an input parameter.

I am using Visual Studio 2008 and C# 3.5

Thanks in advance

2

2 Answers

4
votes

Both are possible.

To hide/unhide a certain field based on a parameter value:

  • create your parameter;
  • right-click on the field you want to hide/unhide and select Format Field... from the menu;
  • select the Common tab in the Format Editor;
  • click on the x-2 button to the right of where it says Suppress - this brings up the Formula Editor for the Suppression condition (the check box to the left of where it says Suppress will unconditionally suppress the field);
  • enter the condition to hide the field - eg. if your parameter is called HideField and you want to hide the field if the parameter has the value 'Y', then enter {?HideField} = 'Y'
  • click the Save and close button in the Formula Editor, and then click OK in the Format Editor.

To change the content of a certain field in the page header and in the details sections based on an input parameter, create a Crystal Formula:

  • create your parameter;
  • create a formula, in the form if {? parameter name } = ' true value ' then { value1 } else { value2 }
  • insert your formula into the page header and details sections of your report where you want to see the parameterised content field.
1
votes

This is how you would hide a field - Without a condition - in crystal report

Right click over the field name in Crystal Reports design

  1. Select Format Field...

  2. Click on Common tab

  3. Check off the Suppress checkbox

The field is now Hidden!