2
votes

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.

3

3 Answers

9
votes

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.

1
votes

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}

0
votes

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.