Checking for Null in date field

ReneeB

Registered User.
Local time
Today, 14:21
Joined
Jan 8, 2014
Messages
23
Hi everyone.

I've been dinking around with this problem for longer than I care to admit. This is the deal....I have a date field on a form that needs to be checked to determine if the user needs to put data in the next field. Not everyone will have a date (CCare_Date) but if they do I want to be able to put in the provider that wrote the order (cc_by), otherwise I want to skip the cc_by field.
That isn't working if the field is left blank.

Here's my code:

Private Sub CCare_Date_click()
If Me.CCare_Date Is Not Null Then

If Me.CCare_Date > #2/28/2012# Then
Me.cc_by.Enabled = True
End If

Else
Me.cc_by.Enabled = False
End If
End Sub

If: I enter or tab past the CCare_Date I end up in the cc_by field -- wrong
I put in a date earlier than 2/28/12 it doesn't stop -- right
(I'll error check the date later)
I put in a date later than 2/28/12 it stops in the cc_by field -- right

I have tried several iterations of this. I'm thinking it has something to do with checking a date field for a null value??....??? I was successful doing this in another field but it wasn't a date field.

Any & all guidance is appreciated,
Thanks all,
Renee
 
Try:-



Code:
If IsDate(Me.CCare_Date) Then
 
Thanks Uncle Gizmo.
Unfortunately no success. The logic works if I put in a date but if it's Null I still end up in the cc_by field. I renamed a couple of the fields because I had them the named the same as the control - I thought that may be the problem - nope. ?????????:banghead:
Thanks,
Renee

This is it:

Private Sub CC_Date_afterupdate()
If IsDate(Me.cc_date) = True Then

If Me.cc_date > #2/28/2012# Then
Me.cc_by.Enabled = True

Else

Me.cc_by.Enabled = False

End If

Else
Me.cc_by.Enabled = False
End If

End Sub
 
Ah! so maybe you need to use setfocus?
 

Users who are viewing this thread

Back
Top Bottom