开发者

Global variable in crystal reports

开发者 https://www.devze.com 2023-04-11 08:22 出处:网络
I\'m trying to keep a running total of teachers, support staff and managers in crystal reports, I\'ve decided to do this using global variables, I know it\'d be possible in other ways but I want to gi

I'm trying to keep a running total of teachers, support staff and managers in crystal reports, I've decided to do this using global variables, I know it'd be possible in other ways but I want to give 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;

The if statements are开发者_运维百科 definitely firing, but when I come to display the totals at the bottom of the page using the following code, everything is 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

Producing this: [Lewisham] Managers: 0.00 | Teachers: 0.00 | Support: 0.00

Am I using global variables incorrectly? I have tried initialising them with other numbers, but the response is always the same. Any ideas?


You're never assigning your variables any values. ":=" is the assignment operator, not "=". Also, to be on the safe side, the footer formula should have WhilePrintingRecords; at the top.

0

精彩评论

暂无评论...
验证码 换一张
取 消