How to: Specify Expressions in Field Controls

You can display the results of expressions on reports and labels by specifying expressions in Field controls. For example, you can include commonly used expressions and functions to display values such as the following:

  • Displaying the Current Date

  • Displaying Page Numbers

After you add Field controls with expressions that contain fields to the page, they might not display the way you want because of unwanted spacing. To remove unwanted spacing, you can trim and concatenate expressions that contain fields into a single expression. For more information, see Trimming and Concatenating Expressions.

Displaying the Current Date

You can display the current date on the page using a Field control.

To display the current date on the page

  1. Open the report or label in the appropriate designer.

  2. In the designer, add a Field control to the page layout.

    The Field Properties dialog box opens.

    Tip

    You can also double-click the report control in the Report Designer or Label Designer to open the report control properties dialog box.

    Note

    If the _REPORTBUILDER system variable is not set to the default Report Builder or is set to a third-party builder, the Report Expression dialog box displays or a different dialog box might display. For more information, see _REPORTBUILDER System Variable and Report Expression Dialog Box.

  3. In the Field Properties dialog box, click the General tab if it is not selected.

  4. In the Expression box on the General tab, type DATE(), and click OK.

For more information, see DATE( ) Function and General Tab, Report Control Properties Dialog Box (Report Builder).

You can view the date by previewing the report. For more information, see How to: Preview Reports.

Displaying Page Numbers

The Page Header or Page Footer band typically contains a page number. You can display page numbers using a Field control.

Note

If you use a wizard or the Quick Report functionality, a page number is inserted automatically in the Page Footer band.

To display page numbers on the page

  1. Open the report or label in the appropriate designer.

  2. In the designer, add a Field control to the page layout.

    The Field Properties dialog box opens.

    Tip

    You can also double-click the report control in the Report Designer or Label Designer to open the report control properties dialog box.

    Note

    If the _REPORTBUILDER system variable is not set to the default Report Builder or is set to a third-party builder, the Report Expression dialog box displays or a different dialog box might display. For more information, see _REPORTBUILDER System Variable and Report Expression Dialog Box.

  3. In the Field Properties dialog box, click the General tab if it is not selected.

  4. In the Expression box on the General tab, type _pageno, and click OK.

For more information, see _PAGENO System Variable.

You can view the page numbers by previewing the report. For more information, see How to: Preview Reports.

See Also

Tasks

How to: Add Field Controls to Reports
How to: Specify Data Types for Field Controls

Other Resources

Managing Report Controls
Configuring Report Controls
Adding Report Controls
Working with Report Controls