Enable disable a text field based on date field

  • Thread starter Thread starter SPK
  • Start date Start date
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
 
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
 
Back
Top