How can I make a field dependant on other fields?

F

Flyback

I have 3 fields Partswarranty,laborwarranty, and extended warranty as check
boxes. I have other fields that I want to make mandatory(required) if any of
the warranty boxes are checked. Any help would be greatly appreciated.
 
J

John Vinson

I have 3 fields Partswarranty,laborwarranty, and extended warranty as check
boxes. I have other fields that I want to make mandatory(required) if any of
the warranty boxes are checked. Any help would be greatly appreciated.

You can use a Table Validation rule - view the table properties. The
validation rule is a logical expression which must evaluate to TRUE
for the record to be accepted.

It may be easier on both you and the user to enforce these business
rules using VBA code on a Form, however; for example, in the Form's
BeforeUpdate event you could have code like

Private Sub Form_BeforeUpdate(Cancel as Integer)
If Me![partswarrenty] Then ' did user check this box?
If IsNull(Me!txtPartsWarrentyTerm) Then
MsgBox "Please fill in term of the parts warrenty", vbOKOnly
Cancel = True ' don't update the record until corrected
Me!txtPartsWarrentyTerm.SetFocus
End If
<etc etc>

John W. Vinson[MVP]
Join the online Access Chats
Tuesday 11am EDT - Thursday 3:30pm EDT
http://community.compuserve.com/msdevapps
 
Top