multiple validation rules

  • Thread starter Thread starter Crag Hack
  • Start date Start date
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.
 
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
 
If they're that complex, then build a form for data entry, and make a data
validation routine.
 
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).
 
Back
Top