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

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!
 
B

Beetle

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.
 
K

K. Boomer

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!
 

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