Stupid Me or Stupid VBA One or the other...

ReAn

Dangerous Programmer...
Local time
Today, 16:39
Joined
Jun 25, 2004
Messages
250
Can someone tell me why when i break on this line, it reports rst("MechHours") is 800

Code:
If rst("MechHours") <> Null Then

But branches to the else block?
 
If not IsNull(rst("MechHours")) Then

???
 
Id still like to know why you cannot use the <> (does not equal) operator.
 
I think it's just a matter of semantics' blurring your logic thinking - Does sound like it should work when you read it though :)
 
A Null is not a value so comparing something to it is meanigless, returns a null, and will never evaluate to True.
Exercise: Debug.Print IsNull(10<>Null)
 
Well, VB/VBA... unlike any other major language (aka C/C++/Java) apparantly dosent have null as a value.

IsNull() func it makes me think that it may be a flag or something.

Because in C++/Java Null has a value and object == null will return true or false.
 
A's no-value value has no value.
to assign a value to the no-value value seems to be a contradiction??

izy
 
When you want to test for null or not null, you MUST use the IsNull() function in VBA (or IsDate() if the field is a date/time datatype) or Is Null or Is Not Null in SQL. Anything compared to null will yield Null as the result so:

Null = Null --> Null
Null <> Null --> Null
Null = something --> Null
Null <> something --> Null

So - all roads lead to Rome, er Null:)

Regardless of the question you ask, if one of the operands is null, the result is not true so it is false.
 

Users who are viewing this thread

Back
Top Bottom