Conditional Required fields

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
 
G

Guest

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
 
G

Guest

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
 

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