[If] Assignment (DB Field Attribute)

Parameter is divided into two parts, the Test and the Result if True. The test comes prior to the keyword of Then and the Result if True comes after.

Description:

The first part of the Test must be a field name in the current scope, a string literal without any spaces, or a number. The next item after a space must be a valid comparison. The final item after another space may be a field name in the current scope, a string literal, a number, or an expression in parentheses. The Result may be either a field name, a string literal, or an expression.

If a boolean True/False is desired to be assigned to the Field, then only state the Test and do not use the Then keyword or a Result. If the Test evaluates to True it will be set to the single character of "y" otherwise it will be cleared.

List of Math & Text Comparison Operations: Here

Example:

- Using [If] as an DB Attribute (Destination is implied by the selected Field)

[If] Firstname = "Bill" THEN "William"

[If] Firstname = ("Bi" & "ll") THEN "William"

[If] Lastname = Firstname THEN Fullname

[If] Lastname = Firstname

- Using [If] as a Top Query assignment operator (Destination must be declared explicitly)

Email [If] Email = "" Then ContactEmail
Email [If] Email = "" Then MemTab.Person.Email