Crystal Reports: How to pass a parameter from a su

2019-03-05 23:25发布

I have a number of subreports in which I calculate totals. In the main report I need the sum of those totals.

I don't know how to get acces to the totals in the subreports.

2条回答
倾城 Initia
2楼-- · 2019-03-05 23:54

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;
查看更多
女痞
3楼-- · 2019-03-06 00:00

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.

查看更多
登录 后发表回答