Required Field Code

3

3rookerbar

I am trying to create code that will make a field required depending on the
value of another field. "Priorpap" is a required field and may contain two
possible values, either 0 or 1. If "priorpap" is equal to 1 then "ppdate"
needs to be a required field. If "priorpap" is equal to 0 then "ppdate" is
not required. Any help would be appreciated.
 
S

scubadiver

Make "PriorPap" default to zero and "ppdate" an optional field.

Put this code in the "before update" event of the form

If me.priorpap = 1 Then
MsgBox "ppdate is now required", vbCritical
Cancel = True
Me!ppdate.SetFocus
End If

I think that should work.
 
M

missinglinq via AccessMonster.com

If me.priorpap = 1 Then
MsgBox "ppdate is now required", vbCritical
Cancel = True
Me!ppdate.SetFocus
End If

And what if ppdate has already been filled in? Won't the above code still
fire? Maybe something like

If me.priorpap = 1 and IsNull(Me.ppdate) Then
MsgBox "ppdate is now required", vbCritical
Cancel = True
Me!ppdate.SetFocus
End If
 
Top