Field required only if visible

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

Dirk Goldgar

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

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