Partager via


Adding Reports and Labels

After you collect and organize your data, you can add reports or labels to your application to print the data or display it on the screen. You can control the data in your report through the data sources you choose, and manipulate and combine raw data with report variables. Report variables store values that are calculated and used in a report.

Controlling Data Sources

To control the data sources for a report, you can define a data environment that is stored with the report or you can activate specific data sources in code each time you run a report. For more information about using the Data Environment Designer, see Creating Forms.

To Add
Always use the same data sources. Tables or views to the report's data environment.
  DOquery or SELECT - SQL to the Init event of the report's data environment.
Use separate sets of data sources. USEtable, USE view, DO query, or SELECT - SQL to the Click event or other code that precedes a REPORT or LABEL command.

If you use a table as the data source, use aliases on the fields in the report only if you don't plan to use the report with any other data source than the table itself. If you use a view or query as the data source and aliases are included in the report controls, the report might display the same record repeatedly on the report page.

Controlling Record Order

You can use the data sources used by the report to control the order the records print in your report. The records are processed and printed in the order they appear in the table, view, or query. To order the records in a table, you can set an index in code or as part of the report's data environment. For a query, view, or SELECT – SQL code, you can use the ORDER BY clause. If you don't order the records using the data sources, the only way to use just the report to order the records is through the ORDER property on a cursor in the data environment.

Controlling Record Selection

In addition to the order records appear in the report, you can select which records are printed by using the data source, the report printing options, or a combination of both.

To use Add
View or query Conditions in the Filter tab
SELECT - SQL WHERE or HAVING clause
Report Designer Setting in the Print Options dialog box
REPORT command Scope, FOR, or WHILE expressions
Table Filtered index

See Also

Displaying Results in a Window | Protecting a Report's Data Session | Refining Page Layout | Integrating Queries and Reports | Adding Label Controls | Selecting, Moving, and Resizing Report Controls | Adding, Copying, and Deleting Report Controls | Data Grouping in Layouts