Defining a computed field

StepsTo add a computed field to a form:

  1. Click the Compute button in the Controls drop-down toolbar, or select Insert>Computed Field from the menu bar.

  2. Click where you want the computed field.

    The computed properties of the field display in the Properties view:

    Shown is the General tab page of the Properties view with drop down list boxes for Alignment, which is blank, and Border, with the value No Border ( 0 ). At bottom is a scrollable display area labeled Compute Expression.
  3. Do one of the following:

About the Modify Expression dialog box

The Modify Expression dialog box provides you with lists and buttons to help you create the computed field:

The sample shows the Modify Expression dialog box. At top is a scrollable input area labeled Expression. At bottom left are buttons with the symbols for addition, subtraction, equals, and division, and right and left parentheses. Next are a scrollable display of Functions such as abs ( x ) and asc ( s ) and a scrollable display of Columns showing column names such as employee _ street and employee _ city.

The Modify Expression dialog box contains:

Entering the expression

You can enter any valid expression when defining a computed field. You can paste operators, columns, existing computed fields, retrieval arguments, and functions into the expression from information in the Modify Expression dialog box. You can use the + operator to concatenate strings.

NoteInfoMaker expression The expression you are entering is an InfoMaker expression; it is not a SQL expression processed by the DBMS. The expression follows InfoMaker rules. For complete information about expressions, see Chapter 23, “Operators and Expressions.”

Examples

Here are some examples of computed fields:

To display

Enter this expression

Current date

Today( )

Current time

Now( )

Concatenation of Fname and Lname columns for each row

Fname + " " + Lname

Monthly salary if Salary column contains annual salary

Salary / 12

Four asterisks if the value of the Salary column is greater than $50,000

IF(Salary> 50000, "****", "")

Average salary of all retrieved rows

Avg(Salary)

Count of retrieved rows, assuming each row contains a value for EmpID

Count(EmpID)

For more information about the functions you can use in computed fields in the Form painter, see Chapter 24, “DataWindow Expression and InfoMaker Functions” and online Help.