The reason your scenario ends up with the total count in the first footer is because all the sections trigger on the initial page and are mapped before the pagination occurs that would move overflowing sections to subsequent pages. So you did in fact count ALL the sections on page one.
There are several ways your goal might be accomplished, but one thing you need to make sure is that you have not set your footer field to be a scope of Form or Global. You want the scope to be Section so that each occurrence of the can have a unique value.
1. Depending upon your version (which is always helpful to include when posting a question) you may be able to do a rendition of your second approach. Beginning somewhere around version 11.5, setting a section to Copy On Overflow - as you probably have your footer - will now show additional Print Control options which include the ability to show or suppress the section depending upon whether it is the last page or Not the last page. You could simply have two footers as you suggest. Or you could define 3 footers. The primary - "full" - one that has the bulk of the content and then two small ones that are positioned in over the top of the normal footer to show this count. Using the print control, then only one or the other small sections will appear. Obviously, you do have to calculate your remainder field value for the "last page" section, but that could be done with a normal field or image rule using a DAL script. The others would simply be hard-coded to show 10, if that is your desire.
2. Another method would be to use a PostTransDAL in the AFGJOB, placed "above" the PaginateAndPropagate rule. PandP is a post transaction rule as well that you likely already have near the bottom of your transaction rules. By placing the PostTransDAL just above that rule, you are indicating that you want that rule to run after the pagination has occurred. At that point, you will have pages as the overflow has occurred. If you have the total count in a GVM or go get it again with a DAL CountRec rule, you can easily calculate how many pages you think you should have. Then DAL can be used to assign the appropriate value the page footers. Something like this might work:
#nbr = CountRec("!//Data/Details")
#pcnt = (#nbr / 10) + 1
#dtl = MOD(#nbr, 10)
if (#dtl = 0)
#pcnt -= 1
#dtl = 10
while (#pcnt > 0)
SETFLD(#dtl, "MyField", "MyFooter" & "\" & "#pcnt", "MyForm")
#dtl = 10
In this case, I started the script by checking to see if the form was included. No reason to go to the work if it is not there, right?
Next, I get the count of detail lines. If you had this value in a GVM or something, you could make a different call to pick up your value from wherever.
Then do the math to determine the number of pages you will have, followed by calculating the remainder (Modulo).
If the remainder is zero, that means there is an even number of items and the calculations need to be adjusted. You didn't need the +1 on the page count and you need to start your detail count at 10.
The remainder of the logic will loop through the occurrences of the footer from last to first and assign your field value. You reset the detail count to 10 after the initial one, because all pages except the last will have 10 - by your definition.
3. There is another way that you could accomplish this, but again it depends upon your version. There is a feature called Print-Time fields that use a naming convention to call a DAL script which can return a value for the field. If you were to use that scenario, each of the footer fields would have to calculate on demand at the point when print is occurring. This is similar to how the page numbering fields work, except that you are calling a script to return the value at print time. I won't go into this example as either of the above probably will suffice for your needs.
Dumb of me!!! Yes, Documaker (12.2) - does have options on "Print Control" where I am able to set the (variable) Footer to Last Only! This is precisely I was looking for!
Thank you so much for taking your time and giving me much information!!! Just for kicks, I'll try your 2nd Option as well.