cancel
Showing results for 
Search instead for 
Did you mean: 

Crystal Report Parameter Default Value

Former Member
0 Kudos

Hi All,

I have one issues regarding the parameter in the report.

I have two parameter field in the report. The scenario will be as below:

In my report, i have mobile no & passport no parameter selection. Currently in my report, the selection was like below:

{pax.mobile} = {?mobile} and

{pax.passport} = {?passport}

Formula above was placed in report's select expert. Each time user need to select or enter the two parameter above in order to select the entered data to be reflected into the report. However, my report REQUIRED to allowed null value from the parameter selection. I can enter mobile no but leave passport null, however with the formula above was unable to proceed to refresh the report. I have the formula as below, however it could not be able to work.

(if(hasValue({?mobile}) = true) then {pax.mobile} = '*ALL'

else {pax.mobile} = {?mobile} ) and

(if(hasValue({?patssport}) = true) then {pax.passport} = '*ALL'

else {pax.passport} = {?passport} )

The formula above will display all of the records and sometimes it will b hung.

Appreciated anyone who knows this able to advice.

Thanks.

Regards,

CK

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

I would have thought that if the parameter was Null then hasvalue() would return false

Try



(if(hasValue({?mobile}) = false) then true
else {pax.mobile} = {?mobile} ) and 
(if(hasValue({?patssport}) = false) then true 
else {pax.passport} = {?passport} )

Ian

Former Member
0 Kudos

hi,

Thanks for your feedback.

I have try one of the example below:

if(hasValue({?Country})=false) then true

else {Customer.Country} like '*'&{?Country}

If country parameter is null, it will retrun all country. But i would like to return Country = 'USA' if my parameter value is null.

Is this possible to do it in the formula above? I tried something like below, but if has parameter value it will return the USA as well.

if(hasValue({?Country})=false) then {Customer.Country} = "USA"

else {Customer.Country} like '*'&{?Country}

Former Member
0 Kudos

That will work fine.

You can even have a list

if(hasValue({?Country})=false) then {Customer.Country} in [ "USA", "UK"]

else {Customer.Country} like '*'&{?Country}

Former Member
0 Kudos

That should be


if(hasValue({?Country})=false) then {Customer.Country} in ["USA", "UK"]
else {Customer.Country} like '*'&{?Country}

list of countries wrapped in square brackets and no back slashes, this site does strange things with my code entries.

Ian

Former Member
0 Kudos

i tend to use this

add ALL as the default in the parameter

if ?parameter = 'all' then true else field = parameter.

Answers (1)

Answers (1)

Former Member
0 Kudos

I am having this same issue, but my parameter field is a date field.

If the date parameter field is null then i would like to see all of the information, but if it has a date entered in the parameter field then i would like to see everything from that date on.

Below is the formula that i have created.

if(hasValue({?Start Date})=false) then true

else {archsrsysclasstbl.START_DT} >= {?Start Date}

When I execute the report and not enter a value for the date parameter the report will not execute because it is waiting for a value.

How do i get it to select everything if the parameter is null.