Question

my problem is that in the page header section of the main report I display the value of a shared (Shared NumberVar x) variable

I am trying to modify the contents of this variable in 2 different sections of the report (Section 1 => Shared NumberVar x: = 1, Section 2 => Shared NumberVar x: = 2) then I assign the variable x = 3 in sub report (Shared NumberVar x: = 3 in the sub report)

the problem is that the result of the x variable in the page header section have not changed to 3 and remains 2 after displaying the sub report

Crystal Reports don't allows reading shared variables in the header section as the page header comes before sub report

is there another solution so that I can read a shared variable assigned in a sub report in the header of the main report ?

Was it helpful?

Solution

I'm afraid that's not possible because of the way variables and subreports are evaluated. In the main report you can re-assign a variable pretty much in every section of the report as long as the report hierarchy is correct. You do that with the correct use of WhilePrintingRecords; and WhileReadingRecords; With subreports, even if you declare the variable with WhileReadingRecords; in the subreport, the WhilePrintingRecords; to display your variable gets evaluated at the same time as the subreport. So the subreport has to be placed higher in the hierarchy than the formula that displays your variable. Here is a great diagram on the different passes a report makes when it runs.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top