Crystal Reports: Setting subreport parameters with one main report parameter [duplicate] - crystal-reports

How can we pass a parameter from the main report to a subreport in Crystal Reports XI? I have a parameter in the main report. Now, I want to pass the same parameter to subreports. Please help me.

Right-click on the subreport object and choose Change SubReport Links, then select how the parameter is to be used by the subreport.

Using CodebyMoonlight's solution requires a relation between main report and subreport.
If there is no relation between both of them, you can use Shared Variables to pass values between both of them, as shared variable can be set and displayed anywhere in main report or sub report.
Shared NumberVar x := 5;

Perform following easy steps:
Create New Parameter lets say "StartDate" in Parameter Fields in Field Explorer in Crystal Report
Create New Parameter lets say "StartDateSubReport" in Parameter Fields in Field Explorer in your Subreport
Now in Main report file, Right Click Subreport lets say "EmployeesList.rpt" and click Change Subreport Links menu
Select "StartDate" from Available Fields from Available Fields Tab and click on ">" button to make it vailable to link in subreport
Now bind your "StartDate" which you have made available by selecting it with "StartDateSubReport" in dropdown available in "Subreport Parameter Field to use"

parameter sharing between main report and sub report "Right-click on the subreport object and choose Change SubReport Links, then select how the parameter is to be used by the subreport." works for me

I had the same problem. The main report loaded first and then the subreport. You have to load the subreport before you can use the variable.

I think that using
Right Click and Sub-report Links
or
Shared Var Between Report and Sub-report
Both using Selection formula so it is suitable for limited data only
Selection formula working after loading all records from Database table ... report loading bad performance
so i'm tring to limit rows by passing some parameter from C#/VB and send others from main to sub report
For example if you need the transaction of items in period and you can pass the period parameter from application (c# ..) and using Sub-report Links to send itemID

https://kb.blackbaud.com/articles/Article/52328
Create a parameter field in the main report.
From the main report, right click on the subreport, and select Change Subreport Links.
In the subreport linking window, select the parameter field from the window labeled "Available Fields", and click on the ">" button to move it to the window on the right labeled "Fields to link to"
Below, make sure you have a check next to Select data in subreport based on field.
Below the checkbox, if it is not already there, select the field from the subreport, to which you would like the parameter field linked.
Click OK

Related

Crystal Reports - Subreport with stored procedure as datasource creates a new param and doesn't pass it to the stored proc

Using Crystal Reports XI, I have a main report. In this report, I have a Formula Field named XXXCompanyFilter. This is set programmatically at run time and I want to pass it to a subreport.
I add a subreport that has a stored procedure as an input parameter. The parameter is named #co.
A Parameter Field is automatically created in my subreport called #co.
I return to my main report and right-click the subreport and choose Change Subreport Links. I choose the Formula Field XXXCompanyFilter from the Available Fields list and move it to the Field(s) to link to: list.
At this point I expect to be able to choose the subreport's #co parameter in the Subreport parameter field to use: drop down, but it is not there. I have unchecked the Select data in subreport based on field: checkbox.
I've tried selecting the ?Pm-#XXXCompanyFilter option, and that (I think) causes a new subreport parameter to be created:
After that, I do get the new subreport parameter to show in the drop down:
However, this new parameter doesn't seem to do anything, and I'm still prompted to enter the #co subreport parameter whenever I run the report. If I enter a value for the #co parameter the report returns the data I expect.
I've created several subreports to see if the behavior changes. I've tried it with the subreport wizard and with subreports I've created normally. I always get a 2nd, non-useful subreport parameter and the #co parameter is never set, so I am prompted for it.
I feel like if I could select the #co parameter in the drop down list it would work as needed.
I've checked out multiple SO posts, and I've googled the issue but everything I find says I'm doing it right. What am I doing wrong, or what do I need to do to make the #co parameter available in the drop down?
I solved this by specifying a database field in the Available Fields list when creating the subreport link and following the instructions in my original post.
Apparently it just won't work if you specify a Formula Field in the Available Fields list. I can't find any documentation on this but that's the conclusion I come to after reaching a solution by trial and error.

Detail field, linked to new report

I have a main report in Crystal Reports XI that I am using which has fields ProjectNumber, DateOfEvent1, DateOfEvent2, ProjectCategory.
I would like to either have an additional detail field OR hyperlink one of the existing fields so that on click it will open a new table with other records specific to that row's ProjectNumber.
I've used a parameter field with a subreport but cannot get it to dynamically create reports specific to the clicked row. I can only create full reports with all the fields (i.e. for ALL ProjectNumber).
"Hyperlink to another report object" for an existing field seems like an option, but I can comprehend how that is supposed to work.
Any help would be greatly appreciated.
Add an "on demand" subreport:
insert a subreport; check "on demand subreport"; click "Report Wizard":
click "Link" tab; link main report to subreport:
place subreport in desired location; right click and format report; choose "subreport" tab:
add a formula for both captions

My parameters on my main report won't add to my subreport in crystal reports

I have done this before, where the main report's parameters are passed on to the subreport. Currently, there are 2 parameters from the main report being passed to my subreport, but I need to add 2 more. When I go through the "Change Subreport Links" option and select and add the needed parameters, it simply doesn't save. I am not sure how else to add these.
Steps:
create desired parameters in sub-report
create corresponding parameters in main report
link with 'linking expert'
The datatypes of the parameters fields did not match, so the two were not correlating.

Crystal Report Parameter Link to Sub Report with Command field

I have a main Crystal report which consists of several sub-reports, I managed to link the parameter from main report to sub-report by following this simple steps:
create a parameter ParamOP in main report
insert a sub-report in the main report
right click on sub-report > Change sub report links
select the parameter ParamOP from the "Available fields" window and add to "Fields to link to"
you will notice it will be automatically populated in the "Subreport parameter fields to use" link it to the sub-report field, then click OK
Now, since my sub-report has a command field, how can I display the record in sub-report using the parameter?
Here's my SQL query inside the command, however no data was displayed.
SELECT *
FROM CONFORMEREPORTS
WHERE COVERAGEHEADER = '{Pm-?paramOP}'
ORDER BY [LINENO] ASC

Combine all SSRS reports in the Grid into one report

It should be very simple and should employ multi-value parameters , but not able to figure out how ? This report takes parameters from the GridView I have a gridview in an asp.net web page which has print button for every row to print this report for that row.
Now, there are as many reports as there are rows in the grid.---[This part is done]
So,how about combining all these reports into one single report
You can add a subreport for each one of you reports.
You just create a new report and start inserting subreports in each row.
Check this documentation:
http://msdn.microsoft.com/en-us/library/dd220581.aspx
Here's an example for you:
1 - Create a new report. You can then add a tablix to it, in case you have more info, which is the case in my example. Just don't forget to add a dataset to that tablix if that's your case.
This is how it would look
Each gray line is a subreport.
2 - To insert a subreport just right-click a cell and go to Insert > Subreport
3 - Right-click your subreport, select Subreport Properties and choose your report from the drop-down menu:
4 - You can then set the parameters your subreport will receive:
Case 2: if you don't need a tablix for aditional info, just repeat the same process in a Rectangle.
UPDATE
As I said in my comment, here's one report in which I do exactly what you want:
As you can see the subreports are part of the main report's body that has other data.
I need to repeat these subreports for each record and that's how it is done.
Here you can see the Id being passed as parameter to my subreport:
From what I understood, that's what you want. That way for each record its current Id would be passed to the report. Generating a report with that "dynamic" parameter you mentioned.