Conditional Required fields

J

JodyHow

How can I make fields on a form required under certain conditions? For
example user enters data in field A then they must also enter in fields B and
C.

Thanks

Jody
 
O

Ofer

On the before update event of the form you can enter the code

If me.A=data and (isnull(me.B) or me.B="") then
msgbox "Must enter value in B"
cancel=true ' will cancel the update
me.B.setFocus ' will set the focus to field B
End if
 
O

Ofer

I didn't notice the C, in that case

If me.A=data Then
If isnull(me.B) or me.B="" then
msgbox "Must enter value in B"
cancel=true ' will cancel the update
me.B.setFocus ' will set the focus to field B
End If
If isnull(me.C) or me.C="" then
msgbox "Must enter value in C"
cancel=true ' will cancel the update
me.C.setFocus ' will set the focus to field C
End If
End if
 
Top