Friday, February 24, 2012

Dynamic sub-reports with parameter passing?

Hello -

I wanted to know if we can have a fully dynamic sub-reports in CR. I will explain my scenario below..please let me know how i should proceed. I have two sub-reports which uses two different stored procedures to get the required data. Both the stored procedures will take three parameters each.

Sub-Report1: AIM.rpt which uses stored procedure "aim_sp"
Sub-Report1: IND.rpt which uses stored procedure "ind_sp"

aim_sp will take "start_dt","end_dt" and "unit" as parameters
ind_sp will take "start_dt","end_dt" and "unit" as parameters as well.

My requirement is to get the required parameters from the main report(main.rpt). These two sub-reports are shown using this blank report file. The only functionality of the main.rpt is to embed the two sub-reports and get the three parameters. And then, pass the parameters from main report to the two sub-reports. And then, the sub-reports will use the two sub-reports to run the stored procedures and get the data dynamically.

What i did??
----

I created the blank main.rpt file and created three parameters. And then i attached the sub reports to the main report. The sub-reports are themselves seperate report files which have stored procedure as database fields. But when i refresh the main report, it is totally looking for nine parameters. Three are from the main report file. Next three are from the stored procedure "aim_sp" and the next are from "ind_sp".

How can we link the main report parameters to all the sub-report parameters in the back ground and let it ask only three parameters?

Please advice me...
THanks,Right-click on subreport whilst its embedded on main report, select Change Subreport Links option. I will use date fields as an example.
Select the ? fields (paramater fields) from the "Available Fields" list, and when you add them to "Fields To Link To", you should be able to link them to a data field in your subreport. That's provided you have a date field in your subreport...you'll need one, otherwise you can't do the selection. If you don't want to show the date field in the subreport, suppress it, it will still be evaluated against.
Then in subreport's Report menu, select Edit selection Formula and select Record... option.
formula would look something like this:
{Database.DateField} >={?dteStart} AND {Database.DateField} <={?dteEnd}

That should work, from what I can recall.

dave

No comments:

Post a Comment