Crystal Reports: How to pass a parameter from a subreport to the parent report?

爷,独闯天下 提交于 2019-12-02 09:38:40

You need to look into using Shared Variables, which can be read and written to by both the parent report and its subreports.

Example :

In parent report, a formula to initialise things called 'InitTotal', containing the text :

Shared NumberVar MyTotal := 0;

Place this formula in the report header and suppress it. Add a formula to each subreport called 'AddTotal', containing the text :

Shared NumberVar MyTotal := MyTotal + {FieldToAddToTotal};

Add this formula to the subreport's report footer and suppress it.

Finally, in the report footer of the parent report, add another formula called 'DisplayTotal' containing just the text :

Shared NumberVar MyTotal;

You may also want to consider using a SQL Expression field. It generates a sub-query of sorts in the 'main' query's SELECT clause. As a result, the sub-query must return a scalar value. You can also correlate the sub-query with the main query.

SQL Express fields can also be used in the record-selection formula and will be passed to the database for processing.

See Crystal Reports: Using SQL Expression Fields for more details.

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