How to Define an Optional Lookup Rule

What if you want to create an Employee record if Department Code is unknown? That is, you want to create an Employee initially with an unknown Department Code. When an Employee is later updated, a non-blank Department Code must be looked up on the Departments table.

1.     Open the table xEmployee in the editor. Select the Rules and Triggers tab, and expand the Validation Rules for column xDepartmentCode:

        This column currently has one lookup rule to the xDepartments table. This is applied when the column is updated or is included in the Fields() parameter when adding a record.

2.     Select List Check from the Add menu on the Home ribbon.

3.     Details for the new list check is shown on the Details tab. Complete the List Check rule as follows:

Description

Accept when blank

Rule definition

*blanks

When inserting

Apply when column is used (ADDUSE)

When updating

Apply when column is used (CHGUSE)

In the List

ACCEPT

Not in the list

NEXT

Message Text

Blank value is accepted

        Your Rule definition has added one entry to a list of values, *blanks, which is a System Variable.

4.     With the Accept when blank rule selected on the Rules and Triggers tab, use the Up Arrow toolbar button to move it before the Department in xDepartments rule:

        Your rules for column xDepartmentCode should now look like the following:

5.     Compile the table, ensuring your Compile Options are set to: