I have a parameter that allows multiple values. Its for a name field in my database. What I want to be able to do is allow the user to put in a name and then have crystal fi
Another approach (I thought it made sense to create a separate answer), if you have Oracle, is to make use of the REGEXP_LIKE expression.
SELECT customer_name FROM customers WHERE ( '{?QUERY}'='ALL' OR REGEXP_LIKE(customer_name, '{?QUERY}') )
'A|B|C'
is equivalent to LIKE '%A%' OR LIKE '%B%' OR LIKE '%C%'
.Luckily CR can handle this situation automatically (at least in CR2008, where I just confirmed it). You can just do {?Customer Name}="All" or {NAMEFIELD} like {?Customer Name}
.
It will be up to the end user to use the wild cards appropriately, but you can add a blurb to the parameter's help text or force the *Name* format with an edit mask.
Create a multi-value parameter ({?Customer Name}) with these properties:
Add a row to the parameter's pick-list grid; supply 'ALL' and 'ALL' (without single quotes)
Create a Custom Function (named 'Delimit') with this text:
// Delimit()
// enclose each value in array in **, returning an array
Function (Stringvar Array params)
Split("*" + Join(params, "*,*") + "*", ",")
Modify the report's record-selection formula:
If {?Customer Name}<>"ALL" Then
{TABLE.CUSTOMER_NAME} LIKE Delimit({?Customer Name})
Else
True
Optionally, create a formula to display the parameter's values with this text:
//{@Customer Name}
Join( Delimit({?Customer Name}), ";")