If statement

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

What am I missing here? I have the following if statement:

If MyRS.Fields("Date1").Value < Date And MyRS.Fields("Date2").Value = Null
Then
MsgBox "Late"
Else
MsgBox "On Time"
End If

Date1 and Date2 are date fields. The problem that I am having is that even
if Date2 is null, and Date1 is < today's date, the statement still evaluates
to "On Time" when it should be "Late".

Any help is greatly appreciated.

K
 
When you want to check if a value is equal to null then you should use
isnull([number], instead of Number=null

So try this
If MyRS.Fields("Date1").Value < Date And isnull(MyRS.Fields("Date2").Value)
Then
 
Thank you!

Ofer said:
When you want to check if a value is equal to null then you should use
isnull([number], instead of Number=null

So try this
If MyRS.Fields("Date1").Value < Date And isnull(MyRS.Fields("Date2").Value)
Then

Kim said:
What am I missing here? I have the following if statement:

If MyRS.Fields("Date1").Value < Date And MyRS.Fields("Date2").Value = Null
Then
MsgBox "Late"
Else
MsgBox "On Time"
End If

Date1 and Date2 are date fields. The problem that I am having is that even
if Date2 is null, and Date1 is < today's date, the statement still evaluates
to "On Time" when it should be "Late".

Any help is greatly appreciated.

K
 
Back
Top