Not quite sure what you are looking for exactly, but it sounds like you shared variables and formulae should help.
probably in you group header you would want to set the variable to 0 or 1, then in page header you can add 1 to the variable. shared variables are easy to use in the formula just declare them:
shared numbervar varName;
assignments use := notation
Hope this helps