Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Variable displays 0 when subreport hidden or on demand

Status
Not open for further replies.

gillf

Technical User
Aug 14, 2002
35
GB
CR v9 of SQL db via ODBC.
Report to show costs where a sales invoice has been issued in a given date range - report to show cost summary, but with optional drill-down to cost details.
Due to database structure, I can't link the tables showing detailed sales and costs.
I have a container report for sales and a sub-report in the detail section showing cost details. I am using variables to bring the cost totals onto the main report:

In the subreport GF#1:
WhilePrintingRecords;
SharedNumberVar LabSubVar:= Sum ({@costs total})

In the main report I declare it in the Page header:
SharedNumberVar LabSubVar

Reset it in GF#1:
WhilePrintingRecords;
SharedNumberVar LabSubVar;
LabSubVar:=0;

And use it in GF#1:
WhilePrintingRecords;
SharedNumberVar LabSubVar;
LabSubVar

This works fine all the time the sub-report is visible, but if I suppress the detail section to allow drill-down, or make the report on-demand, the variable returns zero.

Have I encountered something Crystal won't do, or am I doing something exceptionally silly?
 
Subreports won't execute if the section in which they are located is suppressed or hidden, so the shared variables become zero. An on-demand subreport hasn't executed until clicked on, so again, the shared variable would only be populated while the subreport was displayed. You could save a copy of the subreport and place it in the main report, but with all sections within the subreport suppressed, so that the shared variable would be displayed.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top