James213
James213

Reputation: 977

Crystal Reports Parameter display "All" when no value is passed in parameter?

So with the reports i've created they have a set of parameters that when no specific value is past into it, then the report treats it as though you get data for all possible solutions.

Ex: you have the machine name as a parameter and you do not put in a specific machine name passed into the parameter. Then you get the data returned for all possible machine names in the database. An example of what i am talking about is below.

enter image description here

However when i put no value into the parameter field no value gets displayed in the report. What i would like is to have it display "All" into the field instead of it coming back as blank.

So my question is how would i go about displaying "All" where the red circle is in the report instead of it coming up as blank when no value is put in for a parameter?

any help or suggestions are greatly appreciated. Thank you.

Upvotes: 1

Views: 30886

Answers (3)

user2730116
user2730116

Reputation: 1

Crystal 2008 syntax if Parameter is of type number syntax ({?P #}= 0 OR {Command.p} = {?P #} )

if parameter is of type STRING SYNTAX (not HasValue({?D}) OR {Command.d} = {?D})

Upvotes: -1

Lee Tickett
Lee Tickett

Reputation: 6027

It sounds like you already have the record selection sorted. The four fields in the red circle would be like:

if hasvalue({?param}) then
 {?param}
else
 'All';

If any of them aren't string values you may need to do:

if hasvalue({?param}) then
 cStr({?param})
else
 'All';

Upvotes: 9

Ryan
Ryan

Reputation: 7287

Optional parameters require that you use the hasvalue() function to check for the cases when there is no value used. So in your case, if you had

{table.machine_name} = {?machine_name_param}

you would instead have to use

(not(hasvalue({?machine_name_param})) 
or {table.machine_name} = {?machine_name_param})

It's basically just like doing a null check like you would for any database field.

Upvotes: 2

Related Questions