#### Restrictions on changing formula variable data types

The formula variable can be set several times within a single formula. For example, suppose a company has a shipping policy in which orders over $1,000 are insured, but orders below that amount are not insured:

    Rem A formula that returns a String value
    If {Orders.Order Amount} >= 1000 Then
       formula = "Insured shipping"
    Else
       formula = "Regular shipping"
    End If

The above formula returns the text string value "Insured shipping" if the value of the database field {Orders.Order Amount} is greater than or equal to 1000; otherwise, it returns the text string value "Regular Shipping." Text strings are usually just referred to as strings. Notice that the formula variable appears twice in the above example.

If the formula variable is set to a value of one type, it cannot be set to a value of another type later in the same formula. For example, replacing the String "Regular shipping" in the above example with the Number 10 would result in an error since the special variable formula was first set to the String value "Insured shipping."

The reason for this restriction is that Seagate Crystal Reports needs to know in advance what the return type of a formula will be so that it can allocate enough storage for the returned values. This is because different types have different storage requirements. Another reason is that the formatting options available for a formula field depend on its type. For example, a Number field has Number formatting options, such as the number of decimals to display, which do not make sense for a String field.

Note: The special variable formula should not be declared, unlike other variables used in a Basic syntax formula. See Variables.

Seagate Software, Inc. http://www.seagatesoftware.com Please send comments to: techpubs@seagatesoftware.com