Crystal报表,子报表和共享变量

LeB*_*leu 5 crystal-reports

我在页眉中有一个公式@InitVars,其中包含以下内容和类似的行:

shared numbervar runWaste:=0;
Run Code Online (Sandbox Code Playgroud)

在详细信息v中,我有一个子报告,其中包含一个公式@SetRunWaste:

shared numbervar runWaste;
if (OnFirstRecord) then
(
if not(isnull({x.x-or})) and 
not(isnull({x.y-override})) and {x.y-override} = true then
runWaste:={x.x-or} 
  else
runWaste:= {x.x}
);
runWaste
Run Code Online (Sandbox Code Playgroud)

我可以看到子报告中该公式的输出是18.00.

但是,在另一个子报告,详细信息az和详细信息w(作为测试)的主报告中,我都有以下公式@test:

shared numbervar runWaste;
runWaste;
Run Code Online (Sandbox Code Playgroud)

在这两个地方,它显示为0.00.

为什么它显示0不是18?

我正在使用Crystal Reports版本11.0.0.895.

LeB*_*leu 9

问题是@InitVars位于页眉中,而不是报表头.它将每个页面顶部的变量重置为0.

将@InitVars移动到报告标题会修复它,以便在详细信息az中的子报告中显示正确的数字.

当我在主报表中包含变量时,我仍然会看到一些奇怪的行为,但由于这只是用于调试,而不是主要目标,我不在乎.