SELECTCASE

Description

Returns the value from the case string that matches the given expression. If no case matches the given expression, a default value can be defined.

Syntax

SELECTCASE ( expression, "operator1~result1 | operator2~result2 | operatorN~resultN | Else~resultDflt" )

Parameter Description
expression Expression to be evaluated.
case string

A collection of parameters defining each case.

  • A case consists of a value to evaluated against expression and the associated result.
  • The case string is enclosed in quotation marks, with the exception of field references.

Within the case string:

operator One of: =, >, <, >=, or <=
| Separates individual case statements and associated result from other case/result combinations.
~ Indicates the result to return if the associated case satisfies the given expression.

Examples

The following statement examines the value of S1. If S1 equals 1 the function returns A, if the value is 2 the function returns B, and if the value is 3 the function returns C.

SELECTCASE(S1, "=1~A | =2~B | =3~C")

The following statement adds a default value to return if no value matches S1 the function.

SELECTCASE(S1, "=1~A | =2~B | =3~C | ELSE~#NULL!")

The following statement performs the same comparisons as above, using a field reference within the case string.

SELECTCASE(S1, "=1~A | =2~B | =3~" &S2& "| ELSE=#NULL!")