Validation Rule Syntax

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
 
A

Allen Browne

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.)
 
B

bw

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
 
B

bw

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
 
A

Allen Browne

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.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top