Validation Rule Syntax

  • Thread starter Thread starter bw
  • Start date Start date
B

bw

How does one code the following as a Validation Rule:

If this field = "somevalue" then another field must not be null

Thanks,
Bernie
 
For comparing fields, use the validation rule of the table, not that of the
field.

1. Open your table in design view.

2. Open the Properties box (View menu).

3. Beside the Validation Rule, enter:
([Field1] Is Null) OR ([Field1] <> "somevalue") OR ([Field2] Is Not Null)

There are 3 ways this rule can be satisfied:
- Field1 is a null, or
- Field1 has a value other than "somevalue", or
- the only remaining way is that Field2 is not null.

Note: Make sure you use the validation rule in the Properties box (the one
for the table), not the validation rule in the lower pane of table design
(the rule for a field.)
 
Thank you sir!
Bernie

Allen Browne said:
For comparing fields, use the validation rule of the table, not that of the
field.

1. Open your table in design view.

2. Open the Properties box (View menu).

3. Beside the Validation Rule, enter:
([Field1] Is Null) OR ([Field1] <> "somevalue") OR ([Field2] Is Not Null)

There are 3 ways this rule can be satisfied:
- Field1 is a null, or
- Field1 has a value other than "somevalue", or
- the only remaining way is that Field2 is not null.

Note: Make sure you use the validation rule in the Properties box (the one
for the table), not the validation rule in the lower pane of table design
(the rule for a field.)

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

bw said:
How does one code the following as a Validation Rule:

If this field = "somevalue" then another field must not be null

Thanks,
Bernie
 
Allen,

After some consideration of your directions, I realize I still have a
problem. If [Field1] and [Field2] are numbers because they have lookup
tables, how do I check for "somevalue"?

Thanks,
Bernie
 
Enter the number, without the quotes.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

bw said:
Allen,

After some consideration of your directions, I realize I still have a
problem. If [Field1] and [Field2] are numbers because they have lookup
tables, how do I check for "somevalue"?

Thanks,
Bernie


For comparing fields, use the validation rule of the table, not that of
the
field.

1. Open your table in design view.

2. Open the Properties box (View menu).

3. Beside the Validation Rule, enter:
([Field1] Is Null) OR ([Field1] <> "somevalue") OR ([Field2] Is Not Null)

There are 3 ways this rule can be satisfied:
- Field1 is a null, or
- Field1 has a value other than "somevalue", or
- the only remaining way is that Field2 is not null.

Note: Make sure you use the validation rule in the Properties box (the
one
for the table), not the validation rule in the lower pane of table design
(the rule for a field.)
 
Back
Top