A possibility may be that on your page, you have a total number of iterations that is exactly divisible by 13. (maybe 13 or 26 or 39 records, etc...) What will happen is that it will exit and overflow when it reaches the last line because it has reached an iterationcount of 13, but because it's done with all the lines, it produces an extra page.
You need to modify your condition to handle this, and make sure you check if you've reach the last line of data. You could do this in many ways, depending on how your form is built. For example, if you repeat until line 0(the end of the page), you could use this condition:
=(&iterationcount = 13) and (¤t.line < ¤t.lpp)
This will still check for 13 iterations. However, it will only be true if we still haven't reached the last line(¤t.lpp returns the maximum number of lines on your page). If you're on the last line, it will be false, and will not overflow, and therefore, won't be producing blank pages.
A variant of this, you could also stop if you encounter a blank line:
=(&iterationcount = 13) and (@(¤t.line,1,200) <> '')
Could be useful if you're repeating a list of items that stops whenever it encounters a blank line. Again, the exact condition could vary depending on how your form is setup.
Now, doing the other part of what you want to do, print all invoices, and then all statements, could be more difficult using just the simple overflow. The way simple overflow works is that whenever it exits and overflow, it will then try to regenerate ALL the pages, not just the page that called the overflow. So if you have one page for invoices, and one for statements, it will execute invoice, then statement. Thus doing:
Client 1 Ivoice page 1
Client 1 statement page 1
Client 2 invoice page 1
Client 2 Statement page 1
Here's an idea I had that you could try if you wanted to get what you want without having to ressort to PressTalk. You will need PlanetPress Workflow. If you have it, my idea would be to use our custom "Sort for N-Up and Telescoping" plugin(available on our web site: http://www.objectiflune.com/OL/en-CA/Download/ResourceCenter/PlanetPressSuite/Plugin.aspx#1
), and use it to duplicate the records of your data. Check the "Group only" box in order to only duplicate the records, and not actually rearrange them. Don't forget to change the "File Type" to match the type of data that you're using. The result will be your data with duplicated records.
Now, in your form, in your Invoice and Statement pages, you will put the following conditions in their Basic Attributes:
Invoice: =mod(¤t.datapage, 2) <> 0
Statement: =mod(¤t.datapage, 2) = 0
This will print Invoice for odd records, and Statement for even records. This means that record 1 will print Invoice, and record will print Statement. However, because records 1 and 2 are now duplicates, this means that you'll get all the Invoices, and then all the Statements, for one given customer.
Hope this was clear, and that it helps!
RaphaŽl Lalonde Lefebvre