Show/Hide Fields In Crystal Reports Depends On The Parameter Selected

In Crystal Reports, multiple-value parameter is stored as array. To access each element, one can use format as {?FINANCIAL}[1], {?FINANCIAL}[2], etc.

Following is an example how to achieve this task:

Create a formula Show_Me as:

Global StringVar cShow;
cShow:={?FINANCIAL}[1];
If Count({?FINANCIAL})> 1 then cShow:=cShow+", " +{?FINANCIAL}[2];
If Count({?FINANCIAL})> 2 then cShow:=cShow+", " +{?FINANCIAL}[3];
If Count({?FINANCIAL})> 3 then cShow:=cShow+", " +{?FINANCIAL}[4];
If Count({?FINANCIAL})> 4 then cShow:=cShow+", " +{?FINANCIAL}[5];
If Count({?FINANCIAL})> 5 then cShow:=cShow+", " +{?FINANCIAL}[6];
If Count({?FINANCIAL})> 6 then cShow:=cShow+", " +{?FINANCIAL}[7];
If Count({?FINANCIAL})> 7 then cShow:=cShow+", " +{?FINANCIAL}[8];
If Count({?FINANCIAL})> 8 then cShow:=cShow+", " +{?FINANCIAL}[9];
If Count({?FINANCIAL})> 9 then cShow:=cShow+", " +{?FINANCIAL}[10];
If Count({?FINANCIAL})> 10 then cShow:=cShow+", " +{?FINANCIAL}[11];
cShow;

Then, for the fields which will be shown/hidden, program in ‘Suppress’ attribute:

If 'TG' In {@show_me} Then
false
Else
true

Here ‘TG’ is one value in parameter list.

No comments:

Post a Comment

Labels