Specifying a scope for a report to print does not print the correct records
from the table.
The problem is that the DataEnvironment object created when the report was
created performs an implicit GO TOP command as it initializes, even if the
table is already open. This is necessary so that programmatic changes to
Cursor object properties, such as Filter, take effect. A unexpected side-
effect of this recent change is that the Scope clauses (ALL, NEXT, RECORD,
and REST) on the REPORT FORM command do not affect which the records are
For example, if you have a table open and the record pointer is sitting
at record 5, a REPORT FORM <x> NEXT 1 should print record number 5 only.
However, because the DataEnvironment object performs a GO TOP command, the
record pointer is re-positioned as the DataEnvironment object is initiated,
so record number 1 prints - not 5.
To use the REST, RECORD, and NEXT Scope clauses on the REPORT FORM command,
you must prevent the implicit GO TOP command performed by the
DataEnvironment object, which can be done in any one of these ways:
- Remove the table from the DataEnvironment object, and open it before
running the report.
- Keep the table in the DataEnvironment object, but set the AutoOpenTables
property to false, and open the table manually before running the
- Keep the table in the DataEnvironment object, and save and restore the
record pointer before the report actually prints. To do this:
- Set AutoOpenTables to false for the DataEnvironment object.
- In the Init event, do the following:
x=0 && Create a scoped variable
this.opentables && Call the OpenTables method
go (x) && Restore the Record pointer
- In the OpenTables method, save the record pointer:
Microsoft has confirmed this to be a problem in the Microsoft products
listed at the beginning of this article.