Olek Gerasimovic
Olek Gerasimovic

Reputation: 11

Get data from a subreport into the main report

I have made one main report containing a few subreports. At the end I would like to compare some figures from the different parts of the report and also make some calculations with numbers received from the different parts.

Does anybody know a way to get values from the subreport into the main report? All calculations e.g. aggregates that will be made at the end refer only to the dataset for the main part and the other subreports have their own datasets, fetched from other tables.

Upvotes: 1

Views: 11052

Answers (3)

Pankaj
Pankaj

Reputation: 1

I think in RDLC report there is no way for share variable between main report and subreport . So the only way is use another dataset or passing new vaiable. Hope this will help...

Upvotes: 0

Olek Gerasimovic
Olek Gerasimovic

Reputation: 11

I have myself managed to achieve what I expected through using different datasets on the main form which also contains data for the sub reports.

But also I found this way (not tested):

[Reports]![YourReportName]![YourSubReportName]![TheValueFromTheSubReportYouWantToReference]

There is also a long discution about this on SQL Server Central.

Upvotes: -1

Jeroen
Jeroen

Reputation: 63830

I must second @JoaoLeal's comment, I think the method you propose (retrieving data from a subreport in the main report) is technically not possible.

However, there's another way to achieve what you want (show aggregate info on the data displayed in subreports). You could encapsulate your dataset queries in a way that they can be reused by the main report. There are two main/basic options:

  • Use a stored procedure to query the data
  • Use a database view for the data

Your datasets will be very simple: the subreports will select all the data. The main report can then either have a dataset query that aggregates data appropriately from the view / proc, or also retrieve all results and do the aggregation in SSRS.

Upvotes: 2

Related Questions