Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Skip Parameter if Blank?

Status
Not open for further replies.

dancar

Technical User
Mar 23, 2001
32
US
I have a optional parameter field in Crystal 2008 which allows multiple values.

If the user doesn't want to filter by this field, they should leave it blank and see records regardless of what is in this field.

I've tried the following in the Record Selection Formula:

(if {?PARAMETER} <> "" or not isNull({?PARAMETER}) Then {TABLE.FIELD} in {?PARAMETER})

But if there's no value in the parameter I get a "Parameter has no value" message.

When a Parameter allows single values only, I have set the default value to "All" and then used the following:

(if {?PARAMETER} <> "All" then {TABLE.FIELD} = {?PARAMETER})

But if I set the default to "All" in a Multiple-allowed parameter and the user doesn't remove the "All" before adding the values they do want, all records are returned.

Solution?
 
off the top of my head...
but maybe:
if isnull({?PARAMETER}) or {?PARAMETER}="" then "All" else {TABLE.FIELD} in [{?PARAMETER}]
 

You'll have to use the HasValue() function. I don't have CR2008 handy, but it would be something like

if not (hasvalue({?Parameter})) then true
else {table.field} = {?Parameter}

Check the online help for the exact syntax.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top