Testing for Null in Control 
Author Message
 Testing for Null in Control


says...
Quote:
> If Me!txtControl = Null Then
>       debug.print "is null"
> Elseif me!txtControl <> Null then
>       debug.print "is not null"
> End If

> I assumed if one didn't work, the other would... :)  I even set the default
> value of the control =Null and I still don't get anything in the debug window.

Try this in the Debug window:

? Null = Null

THe result is Null, not True, which explains why you can't compare
anything to Null.

OTOH, there's a chance that your text box will look empty, but won't be
Null either (if you're bound to a field that allows zero-length strings).  
It's safer to check with a formula like this:

 If Len(Me!txtControl & "") > 0 Then
    ' You know it's not Null
 End If

That's generally how I do it... -- Ken



Wed, 13 Jun 2001 03:00:00 GMT  
 Testing for Null in Control

Quote:

> THe result is Null, not True, which explains why you can't compare
> anything to Null.

You can check a variable to see if it is null with the IsNull function.
Ken's solution is better if you want to check to see if your control
contains no data,  unless you somehow differentiate between nulls and
zero length strings.  

Quote:
> OTOH, there's a chance that your text box will look empty, but won't be
> Null either (if you're bound to a field that allows zero-length strings).
> It's safer to check with a formula like this:

>  If Len(Me!txtControl & "") > 0 Then
>     ' You know it's not Null
>  End If

> That's generally how I do it... -- Ken

--
Tenbroeck G. Smith MA, Project Coordinator
Rollins School of Public Health - Emory University
1462 Clifton Road, Room 513
Atlanta, GA 30322
Work: (404) 727-8450.  Fax:  (404) 727-7261


Fri, 15 Jun 2001 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST

2. How to test null control ?

3. TEST TEST TEST TEST

4. alt.test,comp.test,misc.test,news.test

5. testing for a null array

6. Test for null value in Outline code field

7. how do you ask a rowfilter to test for null

8. How to test for a NULL return value from FindByValue in vb.net

9. testing for nulls

10. ADO - how to test for empty(null) fields in a recordset

11. Null Null Null!!!!!!!!!

12. Null, Null, Null!

 

 
Powered by phpBB® Forum Software