Generally speaking, when you create a manual subtotal, you create 3 different formulas:
One that clears a Global numbervar that represents the total.
One that accumulates the total.
One that you use to show the total.
All of these formulas should have whileprintingrecords; on the first line
so that they get processed while the report output is being generated.
Each formula has the global numbervar defined so that they all access
the same memory used to store the subtotal.
Here is a simple report that uses BKARCUST to subtotal and grandtotal
OUTINV by state.
http://spectronics.com/dba/Subtotal_example.rpt (Right Click and Save File As .. to get a copy of the file)