Parameter to select multi-value records
Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Technical Questions
Forum Discription: Formulas, charting data, Crystal syntax, etc.
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=22923
Printed Date: 01 May 2024 at 5:20pm
Topic: Parameter to select multi-value records
Posted By: Carol1
Subject: Parameter to select multi-value records
Date Posted: 07 Feb 2021 at 1:22pm
Hi.
I’m having a problem with parameters and hope that someone can provide me with some advice.
I have a table which includes a column that can have one or several values in it, eg only White or White, Grey and Black. It looks something like this:
PROJECT COLOUR
1 White
2 Matte White
3 Pearl White
4 Grey
5 Black
6 White, Black
7 White, Grey, Black
I created a parameter for COLOUR. In record selection TABLE.COLOUR ‘is equal to’ my parameter.
When I run the parameter with ‘White’ selected, Crystal will only return records that have only White entered (Project 1) and no other colour, ie I can’t get records 6 and 7 that also have Grey and Black entered.
I don’t want to change the record selection to ‘is like’ because I expect my parameter would also then return records with Matte White and Pearl White.
My aim is for the parameter to return Projects numbered 1, 6 and 7 which all include ‘White’ but may also include other colours.
How do I achieve this, please?
|
Replies:
Posted By: Valert16
Date Posted: 18 Feb 2021 at 5:46am
If field values with multiple colours are always separated by commas, you can use this sentence in Record Selection:
{Table.COLOUR} = {?paramColour} OR ({Table.COLOUR} like "*" & {?paramColour} & "*" and ({Table.COLOUR} like "*,*"))
|
Posted By: Carol1
Date Posted: 18 Feb 2021 at 10:27am
Yes, Valert16, the values are all separated by a comma. Some minor tweaking to suit my table and the sentence works beautifully. Thank you so much for your help.
|
|