Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Parameter Capturing in CR 2008 Post Reply Post New Topic
Author Message
athar mehar
Newbie
Newbie


Joined: 15 Mar 2013
Location: United States
Online Status: Offline
Posts: 7
Quote athar mehar Replybullet Topic: Parameter Capturing in CR 2008
     Posted: 24 May 2013 at 11:39am
Hi experts,
I am using crystal report 2008 and backend database is sql server 2008.
I created a report based on a stored procedure which has a single parameter. For example @ID =?
I am using a view to give the list of value to this stored procedure for example:

{View I am using}

ID           Request Details
1            Submission to customers
2            request for business
3            request in process
4            request pending
…                   ……….

I am using the ID field of view to give the list of values to the @ID parameter of SP.
And I am using the Request Details Field of the view as the description of the List of values.
So when the user runs the report it only shows the description in the list of values to the user which makes it easier for them for auditing purpose.
Is there any way that I can capture the description (Request Details) selected from the list of values on my report.
I know that I can capture the ID field but I want to show the description (Request Details) field on the report as well. Because if there is no data for the selected ID then it leave my report blank. If I can capture the description then I can show them the values they selected from parameters.
Will appreciate your help.
Thanks in advance.

Request Details
IP IP Logged
Sastry
Moderator
Moderator
Avatar

Joined: 16 Jul 2012
Online Status: Offline
Posts: 537
Quote Sastry Replybullet Posted: 27 May 2013 at 6:45am
Hi

Showing descripiton to your ID is nothing but your ID is referencing the description and not capturing description any where in the report.

I don't think it is possible thorugh crystal reports designer, you may have to try at database end to capture this and display in the report.
Thanks,
Sastry
IP IP Logged
athar mehar
Newbie
Newbie


Joined: 15 Mar 2013
Location: United States
Online Status: Offline
Posts: 7
Quote athar mehar Replybullet Posted: 29 May 2013 at 10:13am
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!
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