View Full Version : Evaluating null in conditional


casey
12-20-2000, 05:15 PM
How do you evaluate a null in a conditional? I'm using an if,then,else statement to evaluate the value returned from a DLookup function. If the function returns a null, I want to assign the value 0 to a variable. This is a simple example:

If varZ = Null Then
varY = 0
Else
varY = 1

However, when function does return a null, somehow the code evaluates a false condition and jumps to the else condition. I must be making a mistake somewhere referring to the "null".

Jack Cowley
12-20-2000, 06:17 PM
Try:

If IsNull(varZ) Then
varY = 0
Else
varY = 1
End If

casey
12-20-2000, 06:22 PM
Thanks Jack. Works great!