Validation Rule On Form

C

charles.kendricks

I have a client form that depends on a client table. One of the fields
in both objects is a pull down which lists the different programs to
which the client can be assigned to (one of which is "Discharged", and
another field is a possible discharge date. I want the form to inforce
the rule by which if the program fields contains "Discharged" then the
DischargeDate field MUST contain a valid discharge date, otherwise the
DischargeDate field should be blank. I have tried applying the
validation rule:

([Program] = "Discharged" And [DischargeDate] Is Not Null) Or
([Program] <> "Discharged" And IsNull([DischargeDate]))

This rule seem to work when applied to the Client table validation
rule, however when I'm using the form I don't get my expected
validation text which is "Invalid Discharge Date". I want the form to
display the validation text and place the user back into the same
record so he/she can correct the error.
 
S

strive4peace

Hi Charles,

Tracking a Program value of Discharge is necessary -- if there is a
date, it was discharged -- if not, then it wasn't... you can always use
a calculated field to show Program...

on a form or report:
controlSource -->
=IIF(IsNull([DischargeDate]),"Not Discharged", "Discharged")

in a query:
field -->
Program: IIF(IsNull([DischargeDate]),"Not Discharged", "Discharged")

If you still want to keep the field... perhaps you set up the rule in
the table AFTER you defined the form... look at the properties on the
Program control in your form and fill out ValidationRule and Validation
Text properties for the control.

When using forms, though, validation is normally done on the form
BeforeUpdate event


Warm Regards,
Crystal
*
:) have an awesome day :)
*
MVP Access
Remote programming and Training
strive4peace2006 at yahoo.com
*
 

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