Friday 21 April 2017

Use Of Crystal Reports Shared Variables

Shared variables are used within Crystal Reports to pass information between various sections of a report and its subreports.
There are lots of "gotchas" when using shared variables, so you must be sure to follow the rules. The most important one to remember is that you cannot use a shared variable before it has been calculated and used on the report.
For example, if you create in the main report:
Shared NumberVar x := 1776;
You will not be able to see the value in the subreport until you actually put the value in the main report,above the subreport. To test this, try putting the value in the report header versus the report footer. Each "band" of the report processes in a particular order, this order must be followed for the shared variable to initialize and display properly in a subsequent report section.
For example: report header, page header, group header 1, group header 2, details, group footer 2, group footer 1 containing subreport, report footer. In this example, you could initialize the variable anywhere in any main-report section except the last two.
In this example, you would have to initialize your variable in the report header for it to appear in the subreport: report header, page header, group header 1 containing subreport, details, group footer 1, report footer.

No comments:

Post a Comment

Control Structures (Crystal Syntax) In Crystal Report : If Expressions (Crystal Syntax) in Crystal Report

Formulas without control structures execute each expression in the formula exactly once when the formula is evaluated. The expressions are...