I am having a problem using a global variable.
I defined the following formula (basic syntax) in the Report Header of my Crystal Report:

global totamt as number
totamt = 0
formula = totamt

In the detail section of my code I defined the following formula:

global totamt as number

if ISNULL({APinter.PymtRevSw}) or {APinter.PymtRevSw} = false then
totamt = totamt + {@amt}
end if

formula = totamt

Both of the above formulas seem to be working. I printed out the totamt on each detail line.

I defined the following formula in my GroupFooter section:

global totamt as number
dim y as number
y = totamt
totamt = 0
formula = y

This formula returns zero for the totamt field.
Could anyone help me?