Required Field Code

  • Thread starter Thread starter 3rookerbar
  • Start date Start date
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.
 
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.
 
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

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000

Message posted via AccessMonster.com
 

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

Back
Top