Get data from a subreport into the main report

时光怂恿深爱的人放手 提交于 2019-12-11 05:13:50

问题


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.


回答1:


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.




回答2:


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...




回答3:


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.



来源:https://stackoverflow.com/questions/13584509/get-data-from-a-subreport-into-the-main-report

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!