multiple validation rules

C

Crag Hack

Hi, I am having trouble setting up some validation rules in the table design
window. Some constraints are: A>=0, A=0 if B>0
What's the correct syntax to put those contraints all in that expression
builder?
Thank you for your help.
 
A

Allen Browne

To compare values across fields, use the Validation Rule of the table, not
those of a field. It's found in the Properties box.

From your example, I think you are asking that if B is positive the A must
be zero; otherwise A can be zero or positive? If that's right, try:
IIf( > 0, [A] = 0, [A] >= 0)

More info:
http://allenbrowne.com/ValidationRule.html
 
S

S.Clark

If they're that complex, then build a form for data entry, and make a data
validation routine.
 
J

John W. Vinson

Hi, I am having trouble setting up some validation rules in the table design
window. Some constraints are: A>=0, A=0 if B>0
What's the correct syntax to put those contraints all in that expression
builder?
Thank you for your help.

You can't do this as a field validation rule, since field validation rules
cannot refer to *other* fields. You can use a Table Validation rule; it needs
to be a logical expression which returns TRUE if the record is valid. In this
case you need some OR logic:

(B > 0 AND A = 0) OR (B <= 0 AND A >= 0)

with perhaps other parenthetical possibilities if A or B can be NULL.

It may be simpler to put this kind of checking in the Form's BeforeUpdate
event (and force all updates to be done using a form).
 

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