Expression Evaluation

dott

Registered User.
Local time
Today, 22:35
Joined
Jun 24, 2003
Messages
56
The expression being evaluated is
if (wdate <> NULL AND wdate < date) then
...
end if


now the error i am getting is "You entered an expression that has no value (2427)

So what i am wondering is is it evaluating the left hand side of the AND expression even though it is seeing that wdate is NULL?

Or is there some other problem here?
 
if (wdate <> NULL AND wdate < date) then
...
end if


AND means both sides have to be true.

If wdate is NULL then it cannot also be a value that is less than date. (Null isn't a value)

Access looks at this and says it is impossible. Any other language would always return False to that logical expression(because they cant both be true) but I guess Access hic-cups.

What you might want is..

if (wdate <> NULL OR wdate < date) then
...
end if

Jewellissa
 
Well the point of adding the 'wdate <> null' was so that it wouldnt attempt to evaluate the 'wdate < date' if wdate was null,
so what i wanted to know was does access evaulate a logical AND statement properly or does it evaluate both sides regardless if the first is false anyway
 
wdate <> NULL does not generate a compile error but it should since it does not work. There is only one way in VBA to test a field for nulls and that is with the IsNull() function. In a query you would use "SomeField Is Not Null" or "SomeField Is Null". I've written a lot here on how nulls work and you can also find good information in help.

if Not IsNull(wdate) AND wdate < date() then

Rich's suggestion also works but obviously only for date fields.
 

Users who are viewing this thread

Back
Top Bottom