Null Value

  • Thread starter Thread starter DAnte
  • Start date Start date
D

DAnte

I am trying to do a comparison within a condition that
says if a field within a subform or a main form is blank
then continue with the condition other wise don't
continue. I have the following comparison:

If MySubForm("MyControlField") = Null Then
...

This seems to be the value of the control field when there
is nothing in it but this condition always comes out to be
false. Is this a valid condition? Is there another way
to write this?
 
DAnte said:
I am trying to do a comparison within a condition that
says if a field within a subform or a main form is blank
then continue with the condition other wise don't
continue. I have the following comparison:

If MySubForm("MyControlField") = Null Then
...

This seems to be the value of the control field when there
is nothing in it but this condition always comes out to be
false. Is this a valid condition? Is there another way
to write this?

You cannot compare anything to Null. You can only test for null values
using "Is Null" in SQL and the IsNull() function in code.

If IsNull(MySubForm("MyControlField")) = True Then
 
Nothing is ever equal to (or not equal to!) Null.

1 = Null is FALSE
1 <> Null is FALSE
Null = Null is FALSE
Null <> Null is FALSE

This is a characteristic property of the "null value" concept.

What you need is the IsNull() function. Check it out in online help.

HTH,
TC
 
TC said:
Nothing is ever equal to (or not equal to!) Null.

1 = Null is FALSE
1 <> Null is FALSE

On a point of order, TC, that's not what I get:-

? 1=Null
Null

? isnull( 1=Null )
True
What you need is the IsNull() function. Check it out in online help.

Quite right!


All the best


Tim F
 
Owwwwwwwoooooooooooooooooooooooowwowooooooo!!

You are of course correct.

I know what I had in mind when I wrote those examples:

"If you say: If 1 = Null then that WILL NOT succeed;"
"If you say: If 1 <> Null then that ALSO will not succeed"
& so on.

The way I wrote it was quite incorrect. You are right to point that out.

Cheers,
TC
 
Back
Top