Table level validation

M

Micky

Forgive me and I am somewhat new to Access. I have have
a table that among others has two columns named "units"
and "unit price". The requirement that I need to make is
as follows. If the "units" column is > 0 then "Unit
price" must be > 0 OR if the "units" column is null or 0
then the "unit price" must be 0 or null also.
I assume this would need to be done in the expression
builder in the table properties in the validation rule.
I tried "[UNITS]> 0 AND [UNIT PRICE] > 0 OR "UNITS" = 0
AND "UNIT PRICE" = 0 " and had no luck at all.

Thanks in advance for helping

Mick
 
J

Jen

From what I know of Access, there is no way of doing what
you're describing. One thing you may want to do is do
your validation/checking in queries and on forms.

Logically, I'm not sure why there's a dependency between
Units and Unit Price. Can't you have a Unit Price even
though there are no Units? If so, you could just make the
validation for Unit Price > 0 regardless of the value in
Units.

I hope this helps you.

Jen
 
V

Van T. Dinh

Very close.

You need parentheses to explicitly specify the order of operations and get
rid of some double-quotes. Try:

([UNITS]> 0 AND [UNIT PRICE] > 0) OR
( ( ([UNITS] = 0) OR ([UNITS] Is Null) ) AND
( ([UNIT PRICE] = 0) OR ([UNIT PRICE] Is Null) ) )
 

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