Naz avatar image
Naz asked

how to pass parameter to ssrs main report and sub report?

Hello there, I have a main report and a sub report in SSRS 2008 R2 that both get same set of parameters from their datasets and their datasets are both stored procedure. Say I have Main.rdl with @param 1, @param2, @ param3.Those parameter belong to the stored procedure that I used as dataset for my Mainrdl. I have Sub.rdl that also uses sproc as dataset with the same parameter belong to sproc (parameters are all the same and get the same value but values are not statice). because those parameters value will be provided at run time I need to know is there any way that I can pass value to both Main and sub at the same time? Thanks
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

Usman Butt avatar image
Usman Butt answered
Since the Main Report Parameters and Sub-report parameters have the same name, you just need to map the sub-report parameters with the respective Main report parameters values. For e.g. for first parameter @param1 Right Click the Sub-Report -> Click Sub-Report Properties -> Click Parameters -> Click Add -> Put param1 in the Name column and put [@param1] (I guess) in the Value column. Same needs to be done for the rest of the parameters. For more details, here is the link to BOL, where the key part of having the same parameter names is already done by you. [How to: Add a Subreport and Parameters (Report Builder 3.0 and SSRS)][1] [1]:
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Pavel Pawlowski avatar image Pavel Pawlowski commented ·
The way @Usmann described really works. You are probably missing the parameter mappints in the queries, or have a wrong order of parameters in report or sub report. If some parameter depends on other parameter (eg. a query is used to fill a parameter values and for that query another parameter is used than such parameter has to be in higher position in the parameters list. Check proper orders and mappintgs of all params. Also in the SSRS log yo uwill find more information why the report doesn't run and probably more detailed error message.
1 Like 1 ·
Naz avatar image Naz commented ·
Thank you much for your respond, I forgot to say those parameters are the parameters of which I used in Sproc to return the result set (Fields that I have in my report) therefore If I had not provide these values before any execution at any mean I had not have any result set to use in report and that is my problem for I think both main and sub will be generated at the same time. So when I used the method you mentioned my report returns "error occurred" and does not run. I don't know if there is a solution to pass the value to Main report and Sub report parameters at the same time and before they executed? Thanks
0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.