Group Footer

While working with group footers, I understand how to put an existing field, create the total, and have it put in a group footer, by location for example, and have the total only be for that location.

When I try the same logic using an integer variable that I create, based on a quantity from the record by location, when it shows up in the group footer, on the first location total is correct, the remaining locations add their total to the location before it.

Example of Code (which is not working)

Posted Service Header - OnPreDataItem()

Posted Service Header - OnAfterGetRecord()
ShopServ := “Posted Service Header”.“Service Order Type”;

CASE ShopServ OF
‘ShopSer’: counting := counting + 1;
‘Emerg’: counting1 := counting1 + 1;
‘FPM’: counting2 := counting2 + 1;
‘FR’: counting3 := counting3 + 1;
‘Sale’: counting4 := counting4 + 1;
‘Warrty’: counting5 := counting5 + 1;
Out := Out + 1;

ShopServTotal := counting;
FPMTotal := counting2;
FRTotal := counting3;

Qty := 1;