Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Pass parameter from main report to sub report Post Reply Post New Topic
Author Message
Bill
Newbie
Newbie
Avatar

Joined: 14 Dec 2007
Location: United States
Online Status: Offline
Posts: 6
Quote Bill Replybullet Topic: Pass parameter from main report to sub report
     Posted: 19 Dec 2007 at 3:43pm
I am working on a report contains a sub report, with one stored procedure for each. However, some of the parameters have to be the same for whatever reason. For instance, in mian report, it has "project", "vendor" and "orderNumber" and in sub report I have them also, with 2 additional parameters. My question is, is there a way for "project, Vendor and Ordernumber" only appear once at the user prompt, not twice. If this can be done how could I pass them to the subreport stored proc? Appreciate you help!

This is for CR10.

Thanks,
Bill
Thanks,
Bill
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 19 Dec 2007 at 7:44pm
Hi Bill,

This is a tricky problem and I cover the details of how to solve it starting on page 361 of my book Crystal Reports Encyclopedia

I'm going t assume that you have the parameters in the subreport working with the stored procedure. The problem you are running into is that when you link the parameters in the main report to the subreport then you get prompted twice for what should be the same parameter.

The problem is that when you link the parameters in the main report to the subreport that you are accepting the default subreport field of "?PM-..." This is a parameter that CR has created by default and "recommends" that you link to by putting it as the first item in the dropdown list of fields. Using this parameter is causing your problem. What you want to do instead, is to ignore the ?PM- parameter and click on the dropdown list and find the existing parameter that you already created for your stored procedure. By linking directly to the parameter created for the stored procedure and not the intermediate ?PM- parameter, you will only get prompted a single time and that same value will be used for both the main report and the subreport. Do this for all three parameters and you should be good to go!

I have tons of tips and tricks for working with subreports in Chapter 9 of my book Crystal Reports Encyclopedia.
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
IP IP Logged
Bill
Newbie
Newbie
Avatar

Joined: 14 Dec 2007
Location: United States
Online Status: Offline
Posts: 6
Quote Bill Replybullet Posted: 20 Dec 2007 at 8:55am
Thanks Brian. I do have your book, just did not read carefully. It did indeed help me solve the problem.
Appreciate your time.
Thanks,
Bill
IP IP Logged
toekneel
Newbie
Newbie


Joined: 25 Apr 2008
Location: United States
Online Status: Offline
Posts: 6
Quote toekneel Replybullet Posted: 25 Apr 2008 at 9:07am
I had just finished reading this section when the issue came up in the company for the first time.  I set things up the way the book described, but I was unable to get rid of the extra set of parameter prompts.  I searched the user's report for any other references to a sub report, but was unable to find any.
 
In this case, the stored procedure for the sub report was the same as the main report, so that makes the parameter names the same as well.  Does this fall into the category defined from the middle of page 402?   Is there a way to work around it?
toekneel
ABQ, NM
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