How to Dynamically Change the Page Length of a Report

ID: Q112838


The information in this article applies to:
  • Microsoft FoxPro for MS-DOS, versions 2.0, 2.5, 2.5a, 2.5b


SUMMARY

Often it is necessary to change the page length of a report dynamically, without editing the report in the Report Writer. You can do this programmatically, as demonstrated below.


MORE INFORMATION

The .FRX (report) file is a database file that can be modified. The page length is stored in the HEIGHT field of this database in the record where the report information is stored. This record can be found by searching for OBJTYPE = 1. For example:


   USE reportname.frx
   IF printer = "laser"
      && The test for platform = "DOS" is for 2.5 reports only
        LOCATE FOR platform = "DOS" .AND. objtype = 1
        REPLACE height WITH 60
   ELSE
        LOCATE FOR platform = "DOS" .AND. Objtype = 1
        REPLACE height WITH 66
   ENDIF
   USE
   REPORT FORM reportname.frx TO PRINTER 
If the report is included in an .EXE or .APP file, it will be read-only. To modify the report, you must copy it to disk first. For example:

   USE reportname.frx
   COPY TO test.frx
   USE test.frx
   IF printer = "laser"
      && The test for platform = "DOS" is for 2.5 reports only
               LOCATE FOR platform = "DOS" .AND. objtype = 1
      REPLACE height WITH 60
   ELSE
               LOCATE FOR platform = "DOS" .AND. Objtype = 1
      REPLACE height WITH 66
   ENDIF
   USE
   REPORT FORM test.frx TO PRINTER
   oldsaf = SET("SAFETY")
   SET SAFETY OFF
   ERASE test.frx
   ERASE test.frt
   SET SAFETY &oldsaf 
NOTE: Do not place the TEST.FRX file in the project. If you do, it will cause the error message "Test.frx could not be found" and you will then be given the option to locate the file. In this case, you must choose the Ignore button in order to proceed without further errors.

Additional query words: FoxDos 2.00r


Keywords          : 
Version           : 
Platform          : 
Issue type        : 


Last Reviewed: August 20, 1999
© 1999 Microsoft Corporation. All rights reserved. Terms of Use.