PRB: IsNull() and IsEmpty() Always Return False on getValue()

ID: Q221764


The information in this article applies to:


SYMPTOMS

False is alwasy returned when calling the IsNull() or IsEmpty() functions on the getValue() method of the Visual InterDev 6.0 Recordset Design-Time Control (DTC) fields collection. This occurs even if there is nothing in the field or the field is null as in the following example:


If IsNull(Recordset1.fields.getValue("fieldname")) Then Blank = True
If IsEmpty(Recordset1.fields.getValue("fieldname")) Then Blank = True 


CAUSE

Null and Empty are special values for variables. An empty string does not equal Empty or Null.

If the field is null or has nothing in it, the getValue() method of the Recordset DTC fields collection will return an empty string regardless of whether the field is null or simply has no data. Hence IsEmpty() and IsNull() return false.


RESOLUTION

To test for an empty field with the getValue() method, compare the value to an empty string (""):


If Recordset1.fields.getValue("fieldname") = "" Then Blank = True 


STATUS

This behavior is by design.

Additional query words:


Keywords          : kbScript kbVisID600 kbGrpASP 
Version           : WINDOWS:6.0
Platform          : WINDOWS 
Issue type        : kbprb 

Last Reviewed: May 26, 1999