Well, the first thing you need to understand is, that a report with a private datasession does not see the data open in the form calling the report, they are seperated. So the report doesn't know your're on a certain record.
And from the other point o view: Only with a private datasession you can open and relate the tables in the report data environment as you did, which is not wrong and indeed a quite simple approach to relate the data, and to have it available for designing the report controls. But in the first does not filter it, so you always report all data.
The scope clause of the REPORT FORM command only can work for reports without a private datasession. This can still have a data environmen with tables in it, but not the table steering the report, that must be the current table already open before the report is started, for the scope clause to take effect.
So the main decision is for private datasession or not. Having the datasession filled is better done with a private datasession, using the current datasession instead, the form or whatever code calling the report is mainly responsible for providing all the tables the report needs. The report still can open tables itself, but if it also opens it's main steering table the current datasession and the code calling the report will have no effect on it.
The problem is, you can't have the best of both worlds:
On the one side: A report being easily adressible by a scope like NEXT 1 will not have the data in it to comfortly design it. You can still set the report controls to yourtable.yourfield, even if the report itself does not open it and will therefor not be working on it's own, independantly of code opening the table before calling the report.
On the other side: A report running on it's own, opening it's tables is working from scratch and not connected to the data you have at hand in the form or other code calling it. The influence from outside then only can be made by variables set to values filtering the data, and the tables or code within the dataenvironment or report control properties then need to be ontrolled by those variables, if you want less than all data.
Anther way inside the report in a private datasession is using a table solely created for the report, which you ZAP and only fill with the data you want reported.
So in your case, you would create a secondary invoice table as reportinvoice.dbf with the same fields an indexes. Replace the invoice table in the report with the reportinvoive table and then, before starting the report ZAP the reportinvoice and put the one record in it you want to report on, via insert into reportinvoice Select * from invoice where id=<<the current id>>
Bye, Olaf.