Conditional Required fields

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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
 
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
 
Back
Top