I've done this many times within Crystal, it just takes some creative thinking!
![[surprise] [surprise] [surprise]](/data/assets/smilies/surprise.gif)
[ol][li]Create a parameter called {?Parameter Type} that has default values of 'ID' and 'Name'. Only allow a single selection and don't allow modification of the value.[/li][li]Create a parameter called {?Parameter Value}. Leave the list of values blank.[/li][li]Modify your Record Selection Criteria to allow for both parameters:
Code:
{table.id} = Switch({?Parameter Type} = 'ID',{?Parameter Value})
Or
{table.name} = Switch({?Parameter Type} = 'Name',{?Parameter Value})
The Record Selection Criteria listed above will return SQL (Database|Show SQL Query) as follows when selecting a Type of 'Name' and a value of 'K, Rhino':
WHERE
(table."ID" = '' OR
table."Name" = 'K, Rhino')
This shouldn't be a problem unless you have low values (not Nulls) stored in the ID or Name fields.
An alternative Record Selection Criteria is:
Code:
(
If {?Parameter Type} = 'ID'
Then {table.ID} = {?Parameter Value}
Else If {?Parameter Type} <> 'ID'
Then False
)
Or
(
If {?Parameter Type} = 'Name'
Then {table.Name} = {?Parameter Value}
Else If {?Parameter Type} <> 'Name'
Then False
)
The above statement returns SQL (Database|Show SQL Query) as follows when selecting a Type of 'Name' and a value of 'K, Rhino':
WHERE
(table."ID" = 'K, Rhinok' OR
table."Name" = 'K, Rhinok')
Since you shouldn't have IDs and Names with the same value, this shouldn't cause any adverse affects and it accounts for low values.[/li][/ol]
Hope this helps, have fun!