|
Solution:
What version of Crystal Reports 2008 are you using?
Crystal Reports 2008 SP5 and higher now let's you show the prompt description instead of the prompt value on the report as Vitaly suggested.
In the Edit Parameter dialog box under "Value Options", you now have an option to either "Show Value" or "Show Description".
If you do not wish to upgrade, here's what you need to do:
Assuming the ID field is a number field, here's what you need to do:
1) Create a formula called 'ID' in the Main report with this code:
stringvar prompt;
numbervar i;
for i := 1 to ubound({?ID}) do
(
prompt := prompt + totext({?ID},0,"") +",";
);
left(prompt,len(prompt)-1);
2) Insert a Subreport on the Report Header. The Subreport should have the table that contains the ID and the Description field.
3) Right-click the Subreport > Change Subreport Links > Move the formula we created from the Panel on the Left to the 'Fields to link to' area (Panel on the right)
4) Uncheck "Select data in subreport based on field" option
5) Go into the Subreport and create a record selection formula like this:
stringvar array arr;
arr := split({?Pm-@ID},",");
totext({Description},0,"") IN arr;
where {Description} is the Database Field for Description
6) Place the Description field on the Details Section and suppress all the other sections.
Refresh the report and you'll see the Descriptions for the prompts you select one below the other on the Report Header.
If you wish to see a comma separated string, then go back to the Subreport and create a formula:
WhilePrintingRecords;
stringvar desc;
desc := desc + {Description} + ", ";
Place this formula on the Details Section and suppress the section.
Create another formula to display the string. Place this formula on the Report footer Section and this section needs to be un-suppressed:
WhilePrintingRecords;
stringvar desc;
left(desc,len(desc)-2);
Increase the width of the field and also right-click the field > format field > check "Can Grow" option.
That's it! Let me know how this goes!
|