[AccessD] A little Null Help Please

Penn White ecritt1 at alltel.net
Tue Feb 14 09:42:38 CST 2006


Here's a nice little function that I found somewhere.  I've removed the 
error checking since the one I use is not the same as everyone elses.  In my 
experience, IsNull tends to miss a few things.

Penn

Public Function Fn_IsNothing(ByVal varValueToTest) As Integer
'-----------------------------------------------------------
' Does a "nothing" test based on data type.
'   Null = nothing
'   Empty = nothing
'   Number = 0 is nothing
'   String = "" is nothing
'   Date/Time is never nothing
' Inputs: A value to test for logical "nothing"
' Outputs: True = value passed is a logical "nothing", False = it ain't
' Created By: JLV 01/31/95
' Last Revised: JLV 01/31/95
'-----------------------------------------------------------
Dim intSuccess As Integer

  Fn_IsNothing = True

  Select Case VarType(varValueToTest)
    Case 0      ' Empty
      GoTo Exit_Fn_IsNothing
    Case 1      ' Null
      GoTo Exit_Fn_IsNothing
    Case 2, 3, 4, 5, 6  ' Integer, Long, Single, Double, Currency
      If varValueToTest <> 0 Then Fn_IsNothing = False
    Case 7      ' Date / Time
      Fn_IsNothing = False
    Case 8      ' String
        If (Len(varValueToTest) <> 0 And varValueToTest <> " ") Then 
Fn_IsNothing = False
    End Select

End Function




More information about the AccessD mailing list