Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Multi-Value Dyn. Par. Value and Desc in SubRpt Post Reply Post New Topic
Author Message
cjbarth
Newbie
Newbie


Joined: 24 Sep 2010
Online Status: Offline
Posts: 2
Quote cjbarth Replybullet Topic: Multi-Value Dyn. Par. Value and Desc in SubRpt
     Posted: 24 Sep 2010 at 11:16am
I'm trying to get a multi-value dynamic parameter to have it's value and description show up in a sub report. I can easily get the value to show up, however, I can't figure out how to get the description to show up too.

What I've done is create a loop that contatonates all the values of the array together using:


RptValues := RptValues + ", " + CStr({?MyParaArray}[index])


However, I can't figure out what the logic would be to have the description in my created string as well. I was thinking something like:


RptValues := RptValues + ", " + CStr({?MyParaArray}[index]) + " - " + {?MyParaArray}[index].Description


Of course that doesn't work, but there has to be something that does. Does anyone have any ideas?

Edited by cjbarth - 24 Sep 2010 at 1:36pm
IP IP Logged
cjbarth
Newbie
Newbie


Joined: 24 Sep 2010
Online Status: Offline
Posts: 2
Quote cjbarth Replybullet Posted: 24 Sep 2010 at 1:30pm
I found the answer to my question:

Let's say that the dynamic parameter, MyParameter, based on a view, MyView, with two fields: MyViewValue and MyViewDesc.

1. Add the fields MyViewValue and MyViewDesc to the Details section of the main report which should be in the same section as the subreport.

This will give us the data that we are going to want to show on the subreport. However, we don't want it to show on this report, so we have to hide those fields.

2. In the Format Editor of each of the two fields we just added check the box to enable the Common property Suppress.

This will hide those fields from displaying on the main page. Now we need to collect all those values together.

3. Create a new formula, MyFormula, with the following code in it:


WhilePrintingRecords;
StringVar MyParaList := MyParaList + ", " + Trim(CStr({MyView.MyViewValue})) + " - " + {MyView.MyViewDesc};
If OnLastRecord Then MyParaList := Mid(MyParaList,2);


That will build a list of the MyViewValue and MyViewDesc for each record in the list. We need to limit the list to what we've chosen as a parameters.

4. In Select Expert set MyViewValue to be equal to MyParameter.

That will limit the occurrences of MyViewValue and MyViewDesc to only what we've selected, but this will cause a report for each of those values to be generated all appended end-to-end. We need to only show one copy of the report, not multiple copies. We need to suppress some copies of the report.

5. Go to Section Expert and choose the Details Section and set the Suppress formula to:


Not OnLastRecord


That will suppress all but the last copy of the report from displaying. Now we need to get this new formula over to the subreport. The is done in the traditional way.

6. Edit the Subreport Links to link the MyFormula field.

Once you have the value in the subreport you can do with it as you please. I usually put it in the header with some nice formatting.

It is a shame that Crystal Reports makes this so hard to do. One would think this would be a common operation. If anyone has any suggestions for improving this please feel free to post them here.

Edited by cjbarth - 24 Sep 2010 at 1:35pm
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum