Monday, March 26, 2012

How to share parameter value between main and subreport?

Hi All,

I am really lousy when it comes to creating reports. So I am seeking your expert advise/experience.

I have a report that uses a stored-procedure as its data source. This procedure has a parameter. Within this report, I created a subreport which also sources to yet another stored-procedure that also has a parameter which expects the same value as the param of the main report.

When I run the report, say in preview mode, I do not want to be prompted with the parameter twice (i.e. once for the main report, and another for the subreport). How can I edit/modify subreport so that in its select or formula it will say something like:

{?@.ParamOfSubReport} = {?@.ParamOfMainReport}

Many thanks in advance.

_msd_You need to use shared variable and you can use it anywhere in the report|||Right click on your sub-report and choose "Change sub-report links".

Example:

"?parameter1" in the main report links to "?Pm-?parameter1" in the sub-report, then choose the field in the datasource that the parameter is tested against.

When you enter the parameter in your main report it will be passed to the sub-report preview also.|||How do I pass a value returned from the stored proc in the main report to the sub report. I'm getting an error "cannot link from stored procedure" when I pass the value from main report to subreport using subreport links.

Immediate response would be appreciated. Thanks.|||Assign value to shared variable and use that in Sub report|||Hi, I saw this old thread and I am working on the same issue. I'm working on a simple dumb shell of a report in Crystal 8.5 as a test for how to pass parameters into a sql server 2000 stored procedure via a subreport. I'd like to deliver this as straight Crystal without using vb or other shells to call the report from.

Eventually I need to modify a copy of a main report with data and about 8 subreports, all pulling from stored procedures using one parameter called ID. I am getting many requests for this ID parameter, for each subreport, even though I am linking the parameters via subreport links.

The subreport wants to link into the stored procedure using the parameter name from the stored procedure, which is @.ID. The main report only wants to give the subreport a subordinate link such as ?Pm-@.ID. I cannot name the stored procedure parameter with a name like ?Pm-@.ID because it violates the rules of transact-sql. It sees the hyphen as a subtraction. I can see the logic of using the same variable names, but how do I get rid of that bothersome hyphen?

I have also tried using shared variables and they connect to the subreport ok, but I'm still not closing the loop by linking into the stored procedure based on the shared variable.

I am trying to use the same information in multiple places without making the user enter the same information over and over again.

Has anyone had this problem before?sql

No comments:

Post a Comment