How to Dynamically Change the Page Length of a Report

Last reviewed: April 18, 1995
Article ID: Q112838
The information in this article applies to:
  • Microsoft FoxPro for MS-DOS, versions 2.0, 2.5, 2.5a, and 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 reference words: FoxDos 2.50 2.50a 2.50b 2.00r
KBCategory: kbprint kbprg kbcode
KBSubcategory:


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: April 18, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.