Thursday, January 19, 2012

Subreport basics

            Subreports aren’t a whole lot different in SSRS as they are from any other Reporting Service. For example, in SSRS, Subreports are created the same way normal reports are in your project folder. But, to implement them as subreports, you must
·        Right Click on a cell, Select Insert à Subreport.
·        Next, Right Click on the Subreport cell, and select Subreport Properties.
·        Here, you can change the name, whether it’s visible or not, and adjust its borders. But for now, click the dropdown box for “Use this Report as a Subreport.” Select the report you want to act as a Subreport for this cell.
·        You will also want to go to the Parameters tab. This is how you pass values from the original report to the subreports.
o   The flexible aspect of this is that the report only acts as a subreport for that specific cell. You can place a subreport anywhere inside a cell of a table or matrix.

Passing values to subreports
            Due to the way SSRS does parameters for subreports, it can cause a lot of headaches compared to Crystal.
1.      Take each value from your WHERE statement in your Subreport Query
2.      Add those tables, links, and values to your query in the report calling the subreport.
3.      Select the values and pass them in Subreport Properties.
4.      Test it to make sure the values are getting passed. Be sure to use correct case.
a.      Basically, if your subreport for any main report or otherwise has a WHERE Customer.id = @custid, that value needs to be in a dataset of your main report
            Note:  If you’re using a dropdown parameter list (or in general, another dataset to determine a parameter), you must find the value from clicking the Expression button on the Subreport Properties -> Parameters dialog box. Then, select Datasets and find the dataset with your parameter value. Get rid of the ‘=’ sign when you do this, or it will get angry.

No comments:

Post a Comment