I am confused on the conditional operators of VBA. It probably has something to do with weird type casting, but I am stuck and need some help –
query = "SELECT * FROM [records_table] " & _
"WHERE [po_number] = " & Chr(39) & po_number & Chr(39) & ";"
Set rec_set = data_base.OpenRecordset(query)
MsgBox rec_set.Fields("po_ack")
If rec_set.Fields("po_ack") <> Null Then _
po_ack = True
If rec_set.Fields("po_ack") = Null Then _
po_ack = False
Now, this is supposed to return true, but it returns false? When I msgbox the record set value, I get “11/12/2012”, but when I msgbox the return of the function, it is false?
po_ack stores a Date value, and the value of this particular one is “11/12/2012”, so why when I check it against null, it says that “11/12/2012” == null?
Thanks in advance for any help!
Null is never equal to anything, not even another Null.
Null is never not equal to anything, not even another Null.
Use the
IsNull()function to check whether something is Null.See if the
IsDate()function could be useful for what you want to do. Here are some sample expressions copied from the Immediate window.