Condividi tramite


How to: Control Record Selection in Report Output

When printing a report, you can control the records included by specifying any combination of the following:

  • Quantity of records to include in the report.

  • Range of sequential records to process.

  • Selection criteria that records must meet.

  • Conditions required to continue processing sequential records for the report.

This topic shows you how to control record selection when printing through the user interface. When you use the REPORT FORM or LABEL command to print, you can specify these criteria using scope clauses on the command. For more information, see REPORT FORM Command or LABEL Command.

To control record selection in a report

  1. Choose the Print… option on the File menu, and select Report or Label as the Type of output to print in the Print dialog box. Click the ellipsis (...) button to choose the report or label file (.frx or .lbx) to print. Alternatively, open the report or label in the appropriate designer and click Run Report on the Report menu.

  2. In the Print dialog box, click Options.

  3. In the Print Options dialog box, click Options.

  4. In the Report and Label Print Options dialog box, specify the settings you want:

    • To specify a record quantity or range, in the Scope box, choose the scope setting you want. The default scope, All, processes all records. When choosing Next or Record, you type or choose a number in the box to the right of the Scope box to specify a sequential number of records, or a single record number. When you choose the Rest scope, Visual FoxPro processes all records from the current position of the record pointer through the rest of the records in the file.

    Note

    The results for All, Next, and Rest are influenced by the current index order for the table. The results for Record are not influenced by the current index order because the record pointer does not move. The results for all four choices can be further limited by the other types of record criteria in this dialog box.

    • To specify record selection criteria for non-sequential records, use the For box. Type an expression with which records should be compared. To build an expression, make sure data sources used by the report are open and click the ellipsis (...) button to open the Expression Builder.

    • To specify conditions to meet to continue processing records sequentially, use the While box. Visual FoxPro processes records while the condition you type in the While box evaluates to True (.T.). To build an expression, click the ellipsis (...) button to open the Expression Builder.

    Tip

    If you specify a While condition for a file that is not indexed, the selection process might end before evaluating all the appropriate records. Before printing the report, make sure the source table contains an active and appropriate index for the condition you want to use. Set the record pointer to a record satisfying your While condition.

  5. When you are finished, click OK.

    Tip

    Both While conditions and For selection criteria can include variables as well as data from tables. You can change the contents of the variables dynamically during the report or label run.

For more information, see Report and Label Print Options Dialog Box and Expression Builder Dialog Box

See Also

Tasks

How to: Open Reports and Labels
How to: Generate Output for Reports

Other Resources

Running Reports