Print Page | Close Window

Subreport with parameter from Parent report

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Report Design
Forum Discription: The best way to design a report and problems you have encountered
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=2241
Printed Date: 25 Apr 2024 at 5:13pm


Topic: Subreport with parameter from Parent report
Posted By: krpmsit
Subject: Subreport with parameter from Parent report
Date Posted: 06 Feb 2008 at 3:06am
Hello,
 
I am working with Crystal XI.
 
I have created 3 indivitual reports with parameter.
Like Start date, End Date and User.
 
Now the requirement is need to be in single report.
 
I decided to put as a subreport.
 
From Parent report i need to select the 3 fields
Start date, End date and user . After selected these three fields, it should directly assign to all the 3 sub reports.
 
For testing purpose, i have added these 3 indivitual reports as a subreport of the Main report. when i run the report its showing 9 input parameter. 3 input parameter from each reports.
 
Is any other way to fix this issue. i want only 3 input parameters and it should assign to all the 3 subreports.
 
Kindly clear me on this topic and Thanks in advance.
 
 


-------------
Regards
K. Rajapandian



Replies:
Posted By: rahulwalawalkar
Date Posted: 06 Feb 2008 at 3:25am
Hi,
 
You need to link the main report to three Subreports you have created go to the Subreports individually  then right Click  Select Change Subreport Links
 
Select from Available Fields click > to move to Fields to Link select Subreport Parameter  Field to use from left,
 
if you have no parameters created in subreport Crystal Creates the parameter field such as ?PM-table.fieldname......
 
Check Select Data in Subreport based on Field.
 
in ur case for Main report to subreport links  it will be
First       subreport link Start Date
Second  subreport link Second End Date
Third      subreport link Third User
 
Repeat the steps for all three subreports
 
Cheers
Rahul


Posted By: Evil McBad
Date Posted: 06 Feb 2008 at 6:05am
I have a very similar problem and got as far as linking the reports on the parameter field - however, when I went back into edit the link, it was no longer there.  What am I doing wrong???  Arghhhhhh!!!

-------------
Evil


Posted By: krpmsit
Date Posted: 08 Feb 2008 at 4:02am
Its wonderful .Its working fine. Thanks Walker.

-------------
Regards
K. Rajapandian


Posted By: krpmsit
Date Posted: 08 Feb 2008 at 4:11am
Hi,
 
If your problem is not able to link with mainreport and the Sub report means.
1. Connect table and create the parameter field in Main report.
or
1. Write the query in Command and create the parameter field in Main report.
 
2. Right click on subreport -> Change Subreport link-->
Move the subreport parameter from "Available Fields" to "Fields to link to" list box.
 
3. Select the field from "Fields to link to" Listbox and map the field to "Supreport parameter to use"
What are the parameter field, you have created in main report, it will available in the ""Supreport parameter to use" combo box.
 
The above solution is not working then let us know the problem clearly.
 
 


-------------
Regards
K. Rajapandian


Posted By: Eany
Date Posted: 11 Apr 2008 at 7:52am
I have the same problem, but I am using a Stored Procedure in the subreport, with 2 parameters. There is a Kbase article ID c2014605 describing my scenario, but it doesn't work. When I get to the 'Select data' box, and try to link the formulae from the main report, the parameters from the SP in the subreport are not being displayed in the drop down anywhere, and so I cannot perform any linking.
Any ideas anyone ?
Please !

-------------
Eany


Posted By: imstillfishing
Date Posted: 09 May 2008 at 12:29pm
The solution to this is not as obvious as it might seem.  The devil is in the details so they say.
In Crystal X this approach has worked for me.
 
Follow these steps.
1. Right click subreport and select Subreport links
2. In the left pane (available fields) select your input parameter field and click the right arrow to add it to the right side pane (fields to link to)
3. In the bottom right corner, check the options "Select data in subreport based on field"
4. In the drop down, now select "Report Fields" nothing more.
5. Click OK
6. Go to your subreport and select the record or group filter criteria.
7. You may, or may not see a statement something like this...
"{SO_HEADER.DPT_AUTO_KEY} = {?Pm-DEPARTMENT.DPT_AUTO_KEY}"
in that the parameter field filter was already written for you.... but likely not.
8. however, you should now see your main report parameter field displayed in your "Report Fields" list from which you can choose to filter your sub report data on.
9. Manually write your record or group filter criteria using your newly registered parameter field.
 
NOTE: Let's think about this. A parameter field is defined by you, so Crystal doesn't really know what could be "linkable" to your parameter field. Instead, you must NOT select any of your tables or table fields but choose the "Report Fields" instead. This will add it to your sub report "Report Fields" list as a parameter from which you can manually write your filter statements,etc.


Posted By: imstillfishing
Date Posted: 09 May 2008 at 12:39pm
Forgot a critical step in this explaination - sorry.
You don't actually add the parameter field to your sub report link.
 
First, do the following.
1. in your main report, create a Formula that copies your parameter field.
For example.
Parameter Field called Start Date / it is a Date Field.
Formual Field called strt_date and its value is {?Start Date}
2. Follow the steps outlined above, but select the formula field called @strt_date (or whatever your field is called)
 
Hope this cause too much confusion, and it is helpful.


Posted By: Eany
Date Posted: 09 May 2008 at 12:58pm
Thanks Imstillfishin. I had great difficulty because I used "currentdate" in the formula in the main report. The link to the subreport didn't work, as the parameters were not presented for linking at the bottom left of the screen. It was only when I changed to use "currentdatetime" that the parameters finally appeared for linking, and then it worked beautifully. Many thanks for your response.

-------------
Eany


Posted By: imstillfishing
Date Posted: 09 May 2008 at 1:11pm
Yup - that will work too :) guess I should have stuck with the obvious.
The parameter type must match the field type to link to.
 
Learned something myself. Well, the above mentioned "trick" is a way
to pass a parameter value to a sub report when the field types don't match and you cannot link them properly.
 
I find that if I use date time values in parameter fields, my users get pretty annoyed because they don't know what time to put in.


Posted By: PatrickB
Date Posted: 08 Oct 2008 at 11:45am
Originally posted by Eany

and then it worked beautifully. Many thanks for your response.

I'm also using a subreport with data coming from a stored procedure.  I do NOT want the user prompted for the parameters to pass to the stored procedure but want to use parameters already set on the main/parent report.  I can't figure out how if this is possible.  I can link the parameters on the subreport to those on the main/parent report but it still prompts me for the parameters to pass to the stored procedure.

In your case, Eany, does it still prompt you for the parameters?


Posted By: BrianBischof
Date Posted: 08 Oct 2008 at 12:23pm
This is pretty long and a bit confusing to figure out what part is important. For your question, to do what you want to do (eliminate the duplicate prompts for the subreport), start reading at the post by ImStillFishing on this date/time:
Posted: 09 May 2008 at 12:29pm
 
Read the posts from that point forward and follow those steps exactly.


-------------
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>



Print Page | Close Window