Report update inside loop

Good morning everybody.
I’m trying to print simple labels displaying the customer id and i want to print ONLY labels related to the records where boolean is true.
For now i’m calling the print with an action button and i wrote this simple code:

Of course the code is properly indented, and the report runs after “IF rec.boolean is true”

IF Rec.FINDSET THEN REPEAT
IF Rec.Boolean = TRUE THEN
REPORT.RUN(51008,FALSE,TRUE,Rec);
UNTIL Rec.NEXT = 0;

Maybe i miss something on reports calls, but the result of this code is that it prints only the customer id of the first record(even if boolean is not true) Multiple times(number of records with boolean = true).

If i run this code, only the customer id of the records where boolean = true are displayed, wich is correct.

IF Rec.FINDSET THEN REPEAT
IF Rec.Boolean = TRUE THEN
REPORT.RUN(51008,FALSE,TRUE,Rec);
UNTIL Rec.NEXT = 0;

Can you help me with Code1? Many tanks.

This is happening because there are no filters set on Rec. The REPORT.RUN only uses the filters from Rec. It does not read that record. Rather it uses the filters assigned to Rec to retrieve the records from the database.

Rec.SETRANGE(Boolean, TRUE);
REPORT.RUN(51008.FALSE,TRUE,Rec);

Thanks for the reply, i understand now and made it work.
But i have another problem now. Even if i’m using tmp table, when i print the report i get duplicate records. Can you give me a tip on this also, please?

One of the first analysis steps is to determine if the problem is with the dataset or the layout. Send the report to “Excel - Data Only” and see if the duplicates show up there. If so, the problem is with the dataset. If not, the problem is the layout. That will help deterrmine the next steps.

Thank you again for the reply, i’ll try both.
Before your reply i tried playing with layout and using the Grouping Functionality i “hided” the multiple result, but now i’ll investigate on the root of the problem.

I found out that the duplicates don’t show up in the Excel, so the problem is with the layout.

I’m now facing another problem. I forgot to mention that to populate the page from which i call the report form i’m using a tmp table, which i initialize like this:

InitTempTable(tmp : Record "table")
Rec.DELETEALL;
tmp.SETRANGE(tmp."field1");
IF tmp.FINDSET THEN REPEAT
  INSERT
UNTIL tmp.NEXT = 0;

When i open the page i run this:

OnOpenPage()
InitTempTable(tmp);
Rec.Boolean := FALSE

The goal of the report, is to print only the records where BOOLEAN = TRUE, but when i run the report with this filter it just does not print anything. If i remove the filter, it just prints everything.
Even if i send Rec.SETRANGE(Boolean,TRUE); the REPORT.RUN(5000X,TRUE,FALSE,Rec); will not work, instead only the SETRANGE function will work and the report will print exactly the same result i stated above.

Do you have any suggestion about this?

PS:
from what i understood, I created a report wich points to the main table and i’m passing to the report request page the filtered data from the temp table(page).
When i call the report it gets the filters and gets printed, but i think that the changes on the boolean VALUE made from the user are not passed to the report, but remain local to “Rec” in the page. So it is a scope matter basically.

ps2:
Solved creating a tmp Table with temporary records and launching the report from it.