If statement

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
 
G

Guest

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
 
G

Guest

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
 

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