Given the limitation for using the User Interface to set field-to-field
validation at the table level, why have you decided that you MUST do
this in the table rather than (as you suggested as more appropriate) in
a form?
Regards
Jeff Boyce
Microsoft Office/Access MVP
Hello John,
First I must say that I have been reading, although not posting
questions, to forums for sometime and feel that I have gotten to know
you as well as other MVPs if only by name.
Thank you John and to all who contribute to the forum.
The explanation is perfect and the reminder that I need to cover all
logical combinations is especially appreciated.
Here are the combinations:
Fields individually:
FieldA must be >=1 and not null
FieldB must be >= 0 and not null.
FieldA and FieldB in combination:
If FieldA = 1, then FieldB must = 0
If fieldA =>2, then FieldB must be >= 1.
If FieldB >=1 then field A must be >=1
So the fields would be correct if they appear as:
FieldA FieldB
1 0
2+ 1+
I believe I have covered the possibility of null values in FieldA and
FieldB by setting the properties at the field level as follows:
FieldA
The properties for fieldA (datatype Integer) are:
default value: 1
validation rule: <>0 And Is Not Null
validation text Field A must be greater than >=1.
The properties for FieldB (datatype currency) are:
Default value = 0
validation rule - is not null
I tested the field validation vs the table validation and it does
appear that access will fire the field validation before the record
level validation. So I think I am covered for null values for each
field and zero values for fieldA. Please let me know if my thinking is
incorrect?
I am having trouble with applying logic for the fields in combination.
What I have got thus far is:
([fieldA]>1 And [fldB]>=0) Or ([FieldA]>=2 Or [FieldB]<1)
If you would please help. I am afraid I am just lost in the boolean
logic. For some reason it is alway easier for me to think in terms of
select case and if then statements. If this makes sense
Thank you !
Hello,
I need to set a validation rule for one field based upon value on in a
second field. Typically when I need to validate one field based upon
value
in another field I do so at the form level using vba. I but would like
to
use simpler method at the table level if possible.
The details for the specific rule are:
if fieldA > 1, then fieldB must be >0.
If this validation is indeed something that can only be set at the
form
level and/or only using vba please let me know.
Thank you so much for help with this basic question.
A Field Validation rule cannot reference another field in the table
(the
logic, I'd guess, is that you cannot control the order in which data
is
entered for the fields, so FieldA might not have any value at all at
the time
FieldB is set).
But you can view the Table's properties and put an expression in the
Table
Validation rule:
(FieldA > 1 AND FieldB > 0) OR (FieldA <= 1 OR IS NULL)
You need to cover all the logical combinations, I can't tell if the
second
half of this expression meets your needs.
John W. Vinson [MVP]