How to: Reset Report Variables

You can specify that a report variable be reset to its initial value on entry to a specific report band. By default, Visual FoxPro resets the value of a report variable once at the beginning of a report run, leaving it with the last evaluated value when the report run is complete.

You can also use a Band's On Entry and On Exit expressions to set the value of a report variable.

To reset a report variable

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

  2. On the Report menu, click Variables.

    The Report Properties dialog box opens.

    Note

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

  3. In the Report Properties dialog box, click the Variables tab if it is not selected.

  4. Set the value of Reset value based on:

    • Report to set the variable to its initial value before the report starts processing (default)

    • Page to reset the report variable to its initial value when the Page Header band begins processing.

    • Column to reset the variable to its initial value when the Column Header band begins processing (only available in multi-column layouts).

    • Group: <expr> to reset the variable to its initial value when the Group Header band begins processing (only available when a data grouping has been created).

    • Detail <n> to reset the variable to its initial value when a detail band set begins processing (only available in layouts with multiple detail bands).

      For more information on multiple detail band layouts, see Working with Related Tables using Multiple Detail Bands in Reports.

  5. When you are finished, click OK.

For more information, see Variables Tab, Report Properties Dialog Box (Report Builder).

To reset a variable when entering or exiting a band

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

  2. On the Report menu, click Edit Bands.

  3. In the Edit Bands dialog box, click the report band you want, and then OK.

    The properties dialog box for the report band opens.

    Tip

    You can also double-click the band separator in the Report Designer or Label Designer to open the report band 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 band dialog box displays or a different dialog box might display. For more information, see _REPORTBUILDER System Variable and Report Band Properties Dialog Box.

  4. In the report band properties dialog box, click the General tab if it is not selected.

  5. In the Run expression area, type an expression in the On entry or On exit box that resets the variable when entering or exiting the band. An example of such an expression would be EXECSCRIPT("tVariable = 10") to assign the report variable tVariable the numeric value 10. To build an expression, click the ellipsis () button to open the Expression Builder.

  6. When you are finished, click OK.

For more information, see General Tab, Report Band Properties Dialog Box (Report Builder).

See Also

Tasks

How to: Open Reports and Labels
How to: Define Report Variables
How to: Change Report Variable Order

Other Resources

Working with Report Variables