Enable disable a text field based on date field

S

SPK

I want to disable/enable a text field based on the value in the date field.
can anybody help. I have used the following code for the same but it is
disabling the field always.

Private Sub DOB_AfterUpdate()
If DOB.Value = "" Then
Age_yrs.Enabled = False
Else
Age_yrs.Enabled = True
End If
End Sub
 
M

Marshall Barton

SPK said:
I want to disable/enable a text field based on the value in the date field.
can anybody help. I have used the following code for the same but it is
disabling the field always.

Private Sub DOB_AfterUpdate()
If DOB.Value = "" Then
Age_yrs.Enabled = False
Else
Age_yrs.Enabled = True
End If
End Sub


A date value can never be a zero length string. Unless your
DOB field is really a Text field with its Required property
set to No and AllowZeroLength set to Yes, you need to check
for Null:

If IsNull(Me.DOB) Then
 

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