Field required only if visible

  • Thread starter Thread starter Bellyjeans
  • Start date Start date
B

Bellyjeans

Hi there,

I'm trying to wrap my head around something and am wondering if any of
you marvelous guys could help me! I have a combo box and I've coded
it so that if a certain value is selected (the value is "sent to
scope"), a text box becomes visible so that the user can enter a date
(we'll call the value "date to scope"). Is there a possible way to
make it so that the Date to Scope field is a required field but ONLY
if it is visible?

Thanks so much!
 
Bellyjeans said:
Hi there,

I'm trying to wrap my head around something and am wondering if any of
you marvelous guys could help me! I have a combo box and I've coded
it so that if a certain value is selected (the value is "sent to
scope"), a text box becomes visible so that the user can enter a date
(we'll call the value "date to scope"). Is there a possible way to
make it so that the Date to Scope field is a required field but ONLY
if it is visible?


You'd have to do this with code in the form's BeforeUpdate event. Something
like this:

'----- start of example code -----
Private Sub Form_BeforeUpdate(Cancel As Integer)

With Me![Date to Scope]

If .Visible Then

If IsNull(.Value) Then
Cancel = True
.SetFocus
MsgBox _
"Please enter the Date to Scope.", _
vbExclamation, _
"Value Required"
End If

End If

End With

End Sub
'----- end of example code -----
 
Back
Top