水晶报告中的全局变量

时间:2011-10-06 11:54:29

标签: crystal-reports global-variables

我试图在水晶报告中保持一定数量的教师,支持人员和经理,我决定使用全局变量来做这件事,我知道在其他方面它是可能的,但我想给全球变量a go。

    WhileReadingRecords;
Global NumberVar TotalSManagement;
Global NumberVar TotalSTeachers;
Global NumberVar TotalSSupport;
Global NumberVar TotalLManagement;
Global NumberVar TotalLTeachers;
Global NumberVar TotalLSupport;

if{staff_addresses_txt.Staff category} = "MANA" and {staff_addresses_txt.Name} = "CTK:Lewisham" then
    TotalLManagement = TotalLManagement + 1
else
if{staff_addresses_txt.Staff category} = "TEAC" and {staff_addresses_txt.Name} = "CTK:Lewisham" then
    TotalLTeachers = TotalLTeachers + 1
else
if{staff_addresses_txt.Staff category} = "SUPP" and {staff_addresses_txt.Name} = "CTK:Lewisham" then
    TotalLSupport = TotalLSupport + 1
else
if{staff_addresses_txt.Staff category} = "MANA" and {staff_addresses_txt.Name} = "CTK:St Mary's" then
    TotalSManagement = TotalSManagement + 1
else
if{staff_addresses_txt.Staff category} = "TEAC" and {staff_addresses_txt.Name} = "CTK:St Mary's" then
    TotalSTeachers = TotalSTeachers + 1
else
if{staff_addresses_txt.Staff category} = "SUPP" and {staff_addresses_txt.Name} = "CTK:St Mary's" then
    TotalLSupport = TotalLSupport + 1;

if语句肯定会被触发,但是当我使用以下代码显示页面底部的总数时,一切都是0.00:

Global NumberVar TotalSManagement;
Global NumberVar TotalSTeachers;
Global NumberVar TotalSSupport;
Global NumberVar TotalLManagement;
Global NumberVar TotalLTeachers;
Global NumberVar TotalLSupport;

if {staff_addresses_txt.Name} = "CTK:Lewisham" then
 "[Lewisham] Managers: " & TotalLManagement & " | Teachers: " & TotalLTeachers & " | Support: " & TotalLSupport
else
 "[Sidcup] Managers: " & TotalSManagement & " | Teachers: " & TotalSTeachers & " | Support: " & TotalSSupport

制作:   [Lewisham]经理:0.00 |老师:0.00 |支持:0.00

我是否错误地使用全局变量?我尝试用其他数字初始化它们,但响应总是一样的。有什么想法吗?

1 个答案:

答案 0 :(得分:5)

您永远不会为变量分配任何值。 “:=”是赋值运算符,而不是“=”。另外,为了安全起见,页脚公式应该具有WhilePrintingRecords;在顶部。