I have a table in MS-Access – let’s call it tComputers. Two of the fields in that table are titled Status – with the options of Active, Storage, Deactivated – and DeactivationDate.
If I wanted to make DeactivationDate mandatory if and only if the value of Status is Deactivated, how can I do that?
If I wanted to make DeactivationDate mandatory if and only if the value of status is Deactivated how can I do that?
Conversely, if a Deactivated record later changes Status … say becomes Active … should the DeactivationDate be discarded?
I think you can accomplish this with a table level Validation Rule. With tComputers in Design View, open the property sheet and use this as the Validation Rule property:
Figure out what message you want the users to see when that validation rule is violated and put it in as the Validation Text property. It’s unlikely the default message would mean anything to them.
Although it’s possible, I doubt know how useful this is. The users should be editing data via a form, and that gives you the opportunity to enforce your validation requirements before the database
engine even attempts to save the data … use the Form_BeforeUpdate event as @mwolfe02 described.
Edit: Here is an outline for Form_BeforeUpdate. It assumes you have a combo named cboStatus bound to the Status field, and a text box named txtRetireDate bound to the RetireDate field.