Knowledge Base

How to print specific number of records in detail band

Article ID: 114248

Article Last Modified on 2/22/2005


APPLIES TO


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.

Additional query words: VFoxWin FoxMac FoxDos FoxWin 2.50 2.50a 2.50b 2.50c 2.60 set exact precise RWriter

Keywords: KB114248