Validation Rules

A

armymatt

Hey Ya'll,

I'd like to thank ya'll for your help up front. Here is my dilema. I want
to create a validation rule for one of my tables. Two of my Fields are:


Status
Date

I have it set up so you can choose from a list box for the "Status" field.
I'm trying to make it so you can only enter a date in the "Date" field if
"complete" is selected in the "Status" field.

I am not new to Access but I haven't used it for some time and I'm getting
back into it. Is my problem fixible with out much of a hassle? Again, thank
you for the help
 
B

bhicks11 via AccessMonster.com

How about: set the enabled value of the datefield to false and in the OnExit
event of the Status control put a line of code like this:

If me.status="complete" then
me.datefield.enabled = true
End If

Then the date control will be greyed out unless status=complete. BTW,
shouldn't name a field or control date - system uses that.

Bonnie
http://www.dataplus-svc.com
 
M

Michel Walsh

That sounds like a table design problem rather than a vba problem, isn't it?

Open the table in design view, have the Table Properties Sheet open.

In Validation Rule, type:

(NOT DateFieldNameHere IS NULL) IMP (Status = "Complete")


and, for Validation Text, type:

Cannot supply a date if the status is not marked as "Complete"



Table validation rules can be used to described a condition that must exists
between fields of the same RECORD.

IMP is a Jet defined Boolean operator and stands for IMPLIES which always
return TRUE unless the left argument is true and the right argument is not
true.




Vanderghast, Access MVP
 
D

Dirk Goldgar

Michel Walsh said:
That sounds like a table design problem rather than a vba problem, isn't
it?

Open the table in design view, have the Table Properties Sheet open.

In Validation Rule, type:

(NOT DateFieldNameHere IS NULL) IMP (Status = "Complete")


and, for Validation Text, type:

Cannot supply a date if the status is not marked as "Complete"



Table validation rules can be used to described a condition that must
exists between fields of the same RECORD.

IMP is a Jet defined Boolean operator and stands for IMPLIES which always
return TRUE unless the left argument is true and the right argument is not
true.


Great use of an obscure operator, Michel! If I hadn't taken a course in
symbolic logic in college, I'd never have understood the Imp operator.
 
Top