Access/VBA Library

IsEmptyVar

Returns a Boolean value indicating whether a variable has been initialized and set to a non-empty value.

Syntax

IsEmptyVar( varExpression )
Parameters
Name Type Description
varExpression Variant Required. The variable to be evaluated.
Return value

Boolean

Code
Function IsEmptyVar(ByVal varExpression) As Boolean
    If IsObject(varExpression) Then
        IsEmptyVar = varExpression Is Nothing
    ElseIf IsArray(varExpression) Then
        IsEmptyVar = UBound(varExpression) = -1
    Else
        IsEmptyVar = Trim(Nz(varExpression, "")) = ""
    End If
End Function

Validationtag:Validation

Remarks

  • When varExpression is a String containing only spaces, it is considered to be empty. True is returned in this case.
  • Is an array with no elements is passed to this function also True is returned.