Retrieve record count of subreport in Crystal Reports

醉酒当歌 提交于 2019-12-29 07:08:26

问题


How can I retrieve the record count of a subreport from within the main report?


回答1:


I think this is a dupe, but I'll answer anyway. :)

You can create a formula field on the subreport which contains a shared variable. In the formula you'll set the shared variable to the value of the rowcount field in the subreport.

Then in your main report you will need to create a formula with a shared variable that has the same name as the subreport and then return the value of the shared variable.

Here are some links that may help. http://www.datamanagementgroup.com/Resources/TrainersTalk/trainerstalk_howto_share_subreport_data_with_main_report.asp http://www.ozgrid.com/forum/showthread.php?t=19034




回答2:


  1. Put this formula in your subreport. You can suppress it from display if you like.

    whileprintingrecords;
    Shared numbervar SubRecordCount:=(however you want to count the records in the report);

  2. Put this in your main report. Again, this can also be suppressed.

    whileprintingrecords;
    shared numbervar SubRecordCount;
    SubRecordCount

  3. Use the formula name for #2 for whatever calculations you need.
    IMPORTANT: Due to the fundamental logic of Crystal, you can only use this field if it is BELOW it's subreport.
    Also, as for counting the records in the subreport, I recommend a running total at the bottom of it.




回答3:


here you can retrive sub report count from code side

===========================

CrystalDecisions.CrystalReports.Engine.ReportDocument RepDoc = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

RepDoc.Load(ReportName);

int IntRepCount = RepDoc.Subreports.Count;

===========================

pass this count to your report



来源:https://stackoverflow.com/questions/1268348/retrieve-record-count-of-subreport-in-crystal-reports

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