Inserting layout calculations onto a layout

You can create a layout calculation that displays a calculated value. You can use layout calculations for some tasks in place of merge variables, global fields, or unstored calculation fields. For example, a layout calculation could display the total cost at the bottom of an invoice, or display the name of the account used to print a report without creating a calculation field or setting a variable in a script.

You see the layout calculation value in Browse, Find, and Preview modes, and when you print records.

To insert a layout calculation onto a layout:

  1. In Layout mode, click in the layout where you want to insert the layout calculation, then choose Insert menu > Layout Calculation.

    Don't insert layout calculations over a field or any other object that you want to view.

  2. In the Specify Calculation dialog, enter a formula for your calculation.

  3. To set the field type of the result, choose a data type for Calculation result is <value>, then click OK.

    See About choosing a field type.

A layout calculation, including the specified calculation, (<<ƒ:[calculation]>>) appears on the layout.

To modify a layout calculation:

  1. In Layout mode, right-click the layout calculation, then choose Edit Layout Calculation.

  2. In the Specify Calculation dialog modify the calculation, then click OK.

Important  To ensure that layout calculation values are displayed accurately, each record must be refreshed as it is being browsed, previewed, or printed. You can refresh records manually by, for example, creating a Refresh button that calls the Refresh Window script step, or automatically by creating a script that includes the Refresh Window script step. If you need to refresh only one or a few objects in a window, use the Refresh Object script step.

Example

To create a layout calculation displaying "Enabled" if a field is equal to 1, insert a layout calculation with this content:

Copy
<<ƒ: If ( ExampleTable::ExampleField = 1 ; "Enabled" ; "Disabled" ) >>

Notes 

  • The value of a layout calculation uses the attributes of the text block it is inserted into (or the layout's default text attributes, if the layout calculation was inserted onto the layout by itself). To change the text attributes of layout calculation values, select the entire layout calculation in Layout mode (including the <<, ƒ:, and >> symbols), then select text formatting options.

    To control how numbers, dates, and times are formatted, select the text block, then in the Inspector, click the Data Data tab and choose a formats you want to use in the Data Formatting area.

    For more information, see Formatting text.

  • In Browse mode and Preview mode, a text block displays and prints only as much text as will fit within its dimensions. Because layout calculations often display a variable amount of data, the contents of a text block may be clipped and may not appear in its entirety. If necessary, resize the text block to display all of the text. For information on resizing text blocks, see Resizing and reshaping objects.

  • Changing a field name or table occurrence name in the Manage Database dialog automatically updates fully-qualified field names (table::field) in layout calculations. For field names that aren't fully qualified, you must also change them in layout calculations.

  • You can also add a layout calculation in Layout mode by clicking and holding the Text toolText tool in the status toolbar, then selecting Layout Calculation. See Adding text to a layout.