How to print specific number of records in detail band (114248)



The information in this article applies to:

  • Microsoft Visual FoxPro for Windows 3.0
  • Microsoft FoxPro for MS-DOS 2.0
  • Microsoft FoxPro for Macintosh 2.6a
  • Microsoft Visual FoxPro for Windows 6.0
  • Microsoft Visual FoxPro for Windows 7.0
  • Microsoft Visual FoxPro 8.0
  • Microsoft Visual FoxPro 9.0 Professional Edition

This article was previously published under Q114248

SUMMARY

By using the Report Writer in FoxPro, you can limit the number of records that print in the Detail band when the report has a data grouping.

MORE INFORMATION

FoxPro 2.x Example

The steps below demonstrate how to print only the first ten records from each state in the CUSTOMER database, in a report that is grouped on the STATE field:
  1. In the Command window, issue the following commands:
           USE <FoxPro_directory>\tutorial\customer
           CREATE REPORT
  2. From the Report menu, choose Quick Report, and then choose OK.
  3. From the Report menu, choose Data Grouping.
  4. Choose Add, and then set up the data grouping on STATE.
  5. From the Report menu, choose Variables.
  6. Choose Add, and then create a variable named Count. Assign it an initial value of 0 and a value to store of 1. Under Calculate, select Count, and set Reset to State.
  7. For each field in the Detail band, set up the expression as follows:

    IIF(COUNT<=10,<fieldname>,"")

  8. If you are using FoxPro for Windows or FoxPro for Macintosh, choose the Print When check box from within the Report Expression dialog box, and select Remove Line If Blank.

    If you are using FoxPro for MS-DOS, choose Page Layout from the Report menu, choose Options, and then select the Suppress Blank Lines check box.
  9. Add or move the STATE field to the body of the state data grouping header.
  10. From the Report menu, choose Print Preview to see your example.

Visual FoxPro Example

  1. Open the Orders table.
  2. From the Window menu, choose View Window. In VFP 6.0 and later versions, choose the Data Session window.
  3. Select the Orders table and click Properties.
  4. From the Index Order list box, choose CUST_ID, then choose OK.
  5. In the Command window, type:

    CREATE REPORT

  6. From the Report menu, choose Quick Report, and then choose OK.
  7. Create a data grouping on the Cust_id field.
  8. Create a report variable named Count. Assign it an initial value of 0 and a value to store of 1. Under Calculate, select Count, and set Reset to CUST_ID.
  9. For each field in the Detail band, set up the expression as follows:

    IIF(COUNT<=10,<fieldname>,"")

  10. If you are using FoxPro for Windows, FoxPro for Macintosh or Visual FoxPro 3.0 or later, choose the Print When check box from within the Report Expression dialog box or the Print When tab from the Field Properties dialog box in Visual FoxPro 9.0, and then select Remove Line If Blank.
  11. Add or move the CUST_ID field to the body of the group header.
  12. From the Report menu, choose Print Preview to see your example.

Modification Type:MajorLast Reviewed:2/22/2005
Keywords:KB114248 kbAudDeveloper