Crystal Reports 2008 unable to link parameters to subreport - crystal-reports-2008

In Crystal Reports 2008 I have a main report with arg_beg_date and arg_end_date parameters. I want to pass these to a subreport, but have not been able to. The subreport has a Command with a SQL query in it - SELECT * FROM TXFR to keep it simple. I created two parameters in the subreport named beg_date and end_date, then adding WHERE TXFR_DATE BETWEEN {?BEG_DATE} AND {?END_DATE} to the query. I tried to Change Subreport Links, find arg_beg_date in the Available Fields, and clicked ">" to move it to the Field(s) to link to box.
At that point I only see ?Pm-?arg_beg_date and "Parameter Fields" as choices in the "Subreport parameter field to use" box. I cannot link arg_beg_date from the main report to the beg_date parameter I created in the subreport.
I saw in another question where someone suggested checking the box for "Select date for subreport based on field" and selecting "report fields", but I am unable to do that. It just highlights and selects a field below that in the box.
Any ideas?

I've recently built the same report where the Subreport is a command line. I haven't written up a procedure yet but this is how the parameter should look like if you are passing a parameter from the main report to the sub report.
In your subreport SQL, the parameter must be this
WHERE TXFR_DATE BETWEEN {?Pm-?arg_beg_date} AND {?Pm-?arg_end_date}
Then in your parameter list, create
Pm-?arg_beg_date
Pm-?arg_end_date
In your main report, Change Subreport links...
Add the ?arg_beg_date parameter
Make sure the "Select data in subreport based on field" is unchecked
Do the same for ?arg_end_date parameter
In case you want to pass a field instead of a parameter and you are using a command in your main report, same steps as above but looks like this.
Subreport SQL
{?Pm-Command.FieldName}
Parameter List
Pm-Command.FieldName

I figured out what I was doing wrong. The parameters were not showing up in the list to be linked to, because the types did not match. The parameter type in my main report is DateTime, and the type in my subreport was Date. They have to match exactly.
Thanks for your help.

Related

How pull in fields value from created parameter

I created a parameter [GroupID] that is used to query several datasets in my SSRS report. It is using the field [GroupID] from my GroupList_Rolling12 dataset. An example of [GroupID] is 77610N. When 77610N is selected, all of my datasets are correctly 'filtering' for this [GroupID].
I now need to create a text box that returns the [GroupName] of [GroupID]. In other words, when 77610N is selected from my GroupID parameter, I want the [GroupName] that is associated with the selected GroupID parameter to display.
I'm still very new to SSRS and cannot figure this out. I tried creating the expression =First(Fields!GroupName.Value, "GroupList_Rolling12") but that did not work since it simply returns the first value from the query.
I also tried =First(Parameters!GroupID.Value(0)) but this also did not work
I also tried this expression =Lookup(Fields!GroupID.Value, Fields!GroupID.Value, Fields!GroupName.Value, "GroupList_Rolling12")
)
Can you please help?
You can reference the parameter label directly like this
=Parameters!GroupID.Label
There is no need to put the index on the end (=Parameters!GroupID.Label(0)) unless your parameter is multi-value, in which case it would select the first selected entry.

Crystal Report not filtering SQL records based on selection formula

unfortunately I'm not an expert of Crystal Report, so I'll post here my question hoping for any help about my issue.
I want to display inside my report the result of a filter on a SQL RecordSet; this RecordSet is looked up from an a single table, of which I want to show some fields of my SQL table, while the filter I want to apply is based on a field parameter (defined static) that I'm trying to set programmatically.
Here below I attached my code where I'm applying the record selection formula, I tried also hard-coding the value instead of passing it through a dropdown selection:
ReportDocument RPT_Doc = new ReportDocument();
RPT_Doc.Load(RPT_Path_Name, OpenReportMethod.OpenReportByDefault);
ApplyConnInfos(ref RPT_Doc);
RPT_Doc.SetParameterValue("data_riferimento", "20161001");
RPT_Doc.RecordSelectionFormula = "{viaggi.data_part_pre} = '20161001'";
crystalReportViewer1.ReportSource = RPT_Doc;
In the first image attached you can find the field parameter definition, while second image is the record selection formula I defined inside my report:
The report always shows all the records of my table (more than ten thousand rows), instead of displaying a filtered RecordSet. The odd thing is Preview function from Visual Studio works like a charm; it prompts the field value, once I confirm the value the viewer displays the report with the rows filtered as I expect..
What am I missing from report/C# program configuration to make the record selection work?
Thank you in advance for any suggestion you can give me :)
Leonardo
Ok, finally we got the solution to our issue.
We found the CrystalReportViewer object used to display generated reports has 2 different properties, SelectionFormula and ViewTimeSelectionFormula; both has default value set to empty string.
Below I attached the picture of .Designer.cs file with the 2 properties valued:
We commented those 2 properties and the selection formulas and field parameters applied through code / report designer worked again.

Trying to generate SSRS report based on input parameters in visual studio

I have an AX query dataset that I'm trying to use to generate an SSRS report. I want to the user to be able to enter 2 parameters (Date and ProjectId) and have the SSRS report return a table based on the query using the parameters inputted by the user. Can't write any code so it needs to be purely graphical.
You can simply add your parameters to query as query ranges.
In the AOT, click Queries, and locate the query that you want to define a range for.
Expand the query, click Data Sources, and then expand a data source.
Right-click Ranges, and then click New Range.
Right-click the new range, click Properties, and then select a field in the Field property list.
Type an expression in the Value property to specify which records are retrieved.
here it's a helpful link for creating queries with ranges:
https://msdn.microsoft.com/en-us/library/bb314753.aspx
Here is a walkthrough to follow:
https://technet.microsoft.com/en-us/library/cc636713.aspx

How Can I compare date of main report with a date of subreport to get data?

I have a main report in of visual studio 2010.
It is group RecipeDate and inside its header there is a subreport.
In subreport there is a IssueDate.
I want to s all the issuance in the subreport issued right after/on RecipeDate but before the RecipeDate.
For Example:
If I have a Recipe prepared on 18/11/2013
and started issuing from the day i.e 19/11/2013
and the next Recipe is prepared on 25/11/2013.
so I want to show all the issuance between 18/11/2013 till 25/11/2013
is it possible?
Link the RecipeDateof main report with the IssueDate of the sub report using main report links and in subreport Record Selection formula add a condition like
?RecipeDate=?IssueDate

How to limit filter for sub report graph in crystal report..?

I’m new to crystal reports and I’m using crystal report 11. I have created a crystal report with a sub report and that sub report filtered by 2 user parameters named “EMP_NAME” and “EVALUATION_YEAR”. Within the sub report I insert a group and in group footer I insert a chart. That chart filtered from above 2 user parameters and from group parameter.
The problem is I need to filter my sub report from “EMP_NAME” and “EVALUATION_YEAR” while filtering my chart only from “EMP_NAME” and GROUP PARAMETER.
Is there any way to do this?
Thank you.
Requirements:
subreport displays one employee
subreport displays one year's of employee data
subreport includes a graph of all years' of employee data
Solution:
Create an {?Employee Name} parameter in the the main report; link it to {TABLE.EMP_NAME} in the subreport
Create an {?Evaluation Year} parameter in the main report; create an {?Evaluation Year} parameter in the sub-report; link two parameter fields; DO NOT LINK TO DATA.
Create a graph in the sub-report that will display all years' data (for said employee); place in header section
In the sub-report, insert a group on EVALUATION_YEAR; suppress footer; create conditional formula to suppress header if {EVALUATION_YEAR}<>{?Evaluation Year}; suppress details section.

Resources