Vai a vederti nel manuale la funzione

WhilePrintingRecords

forse può fare al tuo caso.