Can I assign a value for one parameter - crystal-reports

I am using crystal reports 2008. I want to generate a report for which i will get one value from one subreport and i want to pass this value as a parameter so that i can include this value in the sql command.
For eg.
From my subreport i will get customerkey and i want to pass this value in the sql as
{?customerkey}
Sql is 'select card_number from customers where customerkey={?customerkey}'
For this i created parameter in the command and added like this.
But what my problem is this customerkey is getting from subreport(using shared variable).If i get a value customer_key from subreport how will i assign this value to {?customerkey}. I tried like assighning this value but i dont want to popup {?customerkey}this value as a parameter.
Can anyone help? Please

So you want the data shown in the main report to be based on a parameter passed to it from a subreport? I don't think this is possible - the Report Processing Model (described here) states that SubReports are in 'Pass 2', while data retrieval is in 'Pass 1'. This means that the parameter prompt will always appear first.
You might instead be able to have the main report contain TWO subreports, the first of which is used to retrieve the parameter and the second uses it. That can get very messy, especially when dealing with page headers and footers.

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.

Multiple Parameters in crystal report

I have created a crystal report layout with 3 parameter.
The 3 parameters are
1.) Date range
2.) Supplier
3.) Location code
User will always give input to the date range but will select either of these remaining two parameters based on the usage.
Is it possible to configure in one single report with optional option in Crystal layout
Assuming you are not using a very old version of Crystal, when you create or edit a parameter, look at the list of parameter properties: one of them is 'Optional Prompt' -- simply change it from the default of False to True.
Then, in your record select logic you can use the HasValue() function to check whether the user provided a value for that parameter.

Jaspersoft Studio: Force input parameter of subreport to be entered manually

In my main report I get a (small) list of string values from the data base. I then want to use this list for selecting records in a subreport, along with other input parameters:
The user shall be able to select records based on a range of begin and end date -- this is easy using an input parameter of type java.util.Date with "Is For Prompting" set to true. Another criteria shall be one or more items from a list showing values from a data base field. I could define the list in the report template, but then I'd have hard-coded strings (filled from the data base, but at definition time only).
Now the dilemma is: If I define the input parameters in the main report, I cannot get the values for the list beforehand; if I define them in the subreport, I get no prompt at all, so there's no way to set any of them.
So the report requires values for start and end date, and a list of string values to select from (multiple itmes can be selected). This list shall be built from values from the data base. In the subreport all these values shall be joined into a filter for the records. A user shall be able to define the dates and select items from the list manually before executing the report.
Is there a way to achieve this?
After some more hours of trial & error, and some more research, of course, I found that the keyword is "Query-based Input Controls". This documentation describes their creation on the JasperReports Server. Such input controls can be edited in Jaspersoft Studio as well, however, they actually work on the server only. Anyway, this is the solution to my problem.

Ssrs run only one of the subreports based on parameter

I have a report, and the report has 5 subreports. There is a parameter named "SubreportNumber". I want to run one of the subreports, based on that parameter. Just one of them should run. Effectivity is important in my case. Is this possible?
I'm using an IIF statement to hide (using visibility) my reports based on a parameter value, as described above.
Then I take the same approach when specifying the sub-report parameters.
This can basically be done on any one of the parameters, if the report should be showing then pass the parameter, else pass nothing. (If you pass NOTHING as a parameter to the report, it won't run the report, ie. performance increase...)
Example for Year parameter below:
=IIF(Parameters!SubreportNumber.Value = "1","YEAR(NOW)", Nothing)
You can hide the reports you dont want based on your parameter.
To do this: Go the Report's property, under visibility section. Set Show or hide report based on expression. You can write an expression to hide report depending upon your parameter.
This will just hide the reports. Make sure there are no stored procedure or they will be execute irrespective or whether the report is visible or not.

Crystal sub report stored procedure parameter

I'm using Crystal reports designer Version 11.
I have a report which calls a subreport and I have set up linked parameters.
The subreport is using a stored procedure.
I can't see how I feed to the parameters passed to the sub report into the stored procedure that is returning the data.
This is really late to the party, but I'm researching the same problem (I think) and have found a solution. In the main report, right-clck on the sub report and "Change Subreport Links".
In the top section, choose your parameter in the main report and click the right arrow to add to the "Field(s) to link to". In the bottom, sub-report section of the window, change the left side "Subreport parameter field to use" drop-down. It defaults to creating a new parameter in the sub report and you don't want to do that. You want to use an existing paramter (that was automatically added by using the stored procedure). In the drop-down choose that parameter that was auto created by the stored procedure.
Doing this means that you can have a parameter in the main report that you can automatically pass to the subreport which means you don't have to enter the same value for two separate parameters.
I hope this helps. It works great for me.
I understand this question is old but have found no satisfactory answer elsewhere. The simple solution I found is to implement the stored procedure from within a crystal command just like any other command sql. I could not get the parameters to show up in the bottom left drop downs no matter what. Something similar to below where ZNG_PROACTIVE_STREET_SWEEPS is the name of the stored procedure and the two parameters are what the stored procedure takes in.
[dbo].[ZNG_PROACTIVE_STREET_SWEEPS] #StartDate ={?begindate}, #EndDate = {?enddate}
After considering and then some searching, I take back my original answer.
Once you have parameters defined for the SQL Command, they are visible/available as parameters from outside the report. When you set up the links from the calling report to the subreport, the subreoprt parameters will be visible and available and you can link fields from the main report to those parameters.
A recent post in someone's blog covers the same activity with subreports driven from SQL Commands
Using SQL Commands and Parameters
I hope this helps and I hope that my original answer did not negatively affect your progress on your report.
Original answer
You cannot pass parameters to a stored procedure from report objects. The stored procedure will respond to CR Designer when you first reference the SP when you define the report. CR creates links to stored procedure parameters from the data source interface only, not from the report.
You will see an entry in the Parameters objects, but it will be read-only -- you can place it in the display section, but you cannot set it from report formulas, passed values, etc. Using formulas to process data before calling the stored procedure will not work, nor will trying to pass data through subreport links from the main report.
Using other design tools, you can have code that controls the data source interface, and processes data that is passed in parameters, but in CR Designer, you are pretty much left with the bare minimum options. You can right-click on the parameter and do things like set default values, set prompting text, set a pattern / mask for the format, but that's about it.