Default Values

Description

Use Default mode field rule to fill a field in a new record with a default value.

Setting a Default Value 

  1. In the Control Panel select the table and click Table > Edit Field Rules.

  2. Display the Data Entry tab.

  3. Select a Default mode. The options are:

    • "No defaults" - No default values.

    • "Simple default expression" - A simple expression that evaluates to the default value.

    • "Conditional default values" - Multiple expressions that evaluate to different default values.

    • "Use previous value as Default" - Uses the field value from the previous record.

  4. Simple Default Expression 

    If you selected "Simple default expression" in step 3, enter an expression in the Default value field. The expression must evaluate to the same data type as the table field. Click 'xy' to use the Expression Builder to help you define the expression. For example, if the default expression is "USA" for a COUNTRY field, Alpha Anywhere inserts "USA" whenever the cursor arrives at the COUNTRY field in a new record.

    If the field is a character field, the default value must be a character value. All character values will be quoted. Likewise, if the field is numeric, the default must be numeric. This applies to all data types.
  5. Conditional Default Expression 

    If you selected "Conditional default values" in step 3:

    • 1. Enter a default value or expression into the first row of the Default column of the embedded browse. Click 'xy' to use the Expression Builder to help you define the expression. All Default expressions must generate values of the same type as the field for which the rule is defined.

    • 2. Enter a condition expression into the first row of the Condition column. The condition must evaluate to TRUE (.T.) or FALSE (.F.). Click 'xy' to use the Expression Builder to help you define the expression.

    • 3. You may add up to fifteen additional expressions on subsequent rows of the embedded browse.

    • During data entry, Alpha Anywhere evaluates conditional expressions in the order you enter them. It uses the default of the first expression that evaluates to TRUE. All the conditions may evaluate to FALSE for some records; if they do, no default value is used. To solve this problem, you can include a "fall-through" default using the Condition expression .T. (TRUE) as the last line in the table.

  6. Previous Default Value 

    If you selected "Use previous value as Default" in step 3, Alpha Anywhere will insert the value from the previous record.

    • You can use a value in a previous record as the default for a new record. This can be helpful when you enter a series of records that have the same values in some of the fields. For example, if you have multiple sales slips that are entered weekly, you can set a previous default value to enter the date. For each day, you have to enter the date only once. From then on, the date is automatically inserted into the next record's date field.

  7. When Default Values Are Created 

    Normally a default value is created when the cursor enters the field for which the Default rule is defined. You can control when the default value is created.

  8. Check Set default value at start of data entry to have Alpha Anywhere apply default value(s) when the new record is created.

  9. Check At end of enter, set default value if field not touched by user to have Alpha Anywhere apply default value(s) when the record is saved.