Conditions

Because you can define conditions for several objects (fields, compute statements, record selections, and so on), the objects include only records that satisfy the conditions. Although the condition window has several names (such as Records Will Be Selected, Relation Is Valid), you define all conditions in the same way.

You can define a condition on a field or record, making the form access the field or record only if it satisfies the condition. A condition can have up to eight conditional statements. Each conditional statement has a first operand, an operator, and a second operand.

The first operand must be a field, or, more precisely, the value in a field. You can select the first operand from a database file, or you can define a compute field or an array value field. The second operand can be a field or a constant value.

Valid operators are:

  • equal to (=)

  • not equal to ()

  • greater-than (>)

  • greater-than or equal to ()

  • less-than (<)

  • less-than or equal to ()

The following condition is in the Company file. The Company field is the first operand, equal to (=) is the operator, and the value 100 is the second operand. When you run the form, it does not access a record whose Company field has a value of 1 because it does not satisfy this condition. The form accesses a record whose Company field has a value of 100 because it does satisfy this condition.

                      Records Will Be Selected
Where                  Company.Company = 100

You can use the conjunctions And and Or to join conditional statements. The conjunction And states that both conditional statements must be true for the condition to be true. The conjunction Or states that if one of the conditional statements is true, the condition is true.

In the following condition, And joins the two statements. For this condition to be true, the Company field in a record must have a value of 100 and the Location field must have a value of 1.

                      Records Will Be Selected
Where                   Company.Company = 100
  And                  Company.Location = "1"

You can use parentheses (one or two) to clarify a condition when both And and Or join several conditional statements. Without parentheses, the following condition is unclear. Is the condition true when the Company = 100 and the Location is either 1 or 2? Or, is the condition true for all Company numbers when the Location field = 2?

                      Records Will Be Selected
Where                   Company.Company = 100
  And                  Company.Location = "1"
   Or                  Company.Location = "2"

If you place the parentheses as follows, the condition is true if Company = 100 and Location = 1. It is also true if Location = 2, regardless of the value of the Company field.

                      Records Will Be Selected
Where (                 Company.Company = 100
  And                  Company.Location = "1"                     )
  Or  (                Company.Location = "2"                     )

If you place the parentheses as follows, however, the condition is true only when Company = 100 and Location = 1 or 2.

                      Records Will Be Selected
Where                   Company.Company = 100
  And (                Company.Location = "1"     
   Or                  Company.Location = "2"                     )

Relation Check Condition

A relation check condition is a statement that lets a program access a field or record only after verifying that a particular related record exists (or does not exist). You can select one-to-many, conditionally-required, or not-required relations for a relation check condition. You cannot select a one-to-one required relation, because it must always be valid.

The first operand in a relation check condition is the relation. The operator is Exist(s) or Do(es) Not Exist. A relation check condition does not have a second operand.

In the following example, Company is the relation and Exists is the operator. This condition tells the form to access a record only if its Company relation exists.

 Relation is Valid
When                  Relation: Company Exists

Task and Dictionary Conditions

A task condition is a condition defined in a program. You can access a task condition only in the task you define it in. A dictionary condition is a condition defined in a database file. You can access a dictionary condition in any program that uses the file the condition is defined in.