Requiring data in one field based on Yes/No input of another field

  • Thread starter Thread starter K. Boomer
  • Start date Start date
K

K. Boomer

I have two fields on a form of about 20:

Ok to Use (Yes or No combo box)
Notes (text box)

If the user selects No in the Ok to Use field, I want the Notes field
required input or the user will not be able to save or go to next record.

If the user selects Yes in the Ok to Use field, Notes is NOT required for
save or next record.

Thanks for you time and assistance!
 
In the before Update event of the form;

Private Sub Form_BeforeUpdate (Cancel As Integer)

If Me![chkOK] = False Then
If Nz(Me![txtNotes], "")="" Then
MsgBox "You must fill out the Notes section"
Cancel = True
Me![txtNotes].SetFocus
End If
End If

End Sub

Substitute your actual control names for the names inside the square brackets.
 
Beetle, you're my hero. Thanks very much for the quick and helpful response!!

Beetle said:
In the before Update event of the form;

Private Sub Form_BeforeUpdate (Cancel As Integer)

If Me![chkOK] = False Then
If Nz(Me![txtNotes], "")="" Then
MsgBox "You must fill out the Notes section"
Cancel = True
Me![txtNotes].SetFocus
End If
End If

End Sub

Substitute your actual control names for the names inside the square brackets.
--
_________

Sean Bailey


K. Boomer said:
I have two fields on a form of about 20:

Ok to Use (Yes or No combo box)
Notes (text box)

If the user selects No in the Ok to Use field, I want the Notes field
required input or the user will not be able to save or go to next record.

If the user selects Yes in the Ok to Use field, Notes is NOT required for
save or next record.

Thanks for you time and assistance!
 
Back
Top