PRB: IsNull() and IsEmpty() Always Return False on getValue() When the File Is Empty or Contains Null Value (221764)



The information in this article applies to:

  • Microsoft Visual InterDev 6.0

This article was previously published under Q221764

SYMPTOMS

False is always returned when you call the IsNull or IsEmpty functions on the getValue method of the Visual InterDev 6.0 Recordset Design-Time Control (DTC) fields collection. This occurs when 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 if the field is null or simply has no data. Thus, 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.

Modification Type:MajorLast Reviewed:9/18/2001
Keywords:kbCtrl kbDSupport kbprb KB221764