IsEmpty Function

Returns a Boolean value indicating whether a variable (variable: A named storage location capable of containing data that can be modified during program execution. Each variable has a name that uniquely identifies it within its level of scope. A data type can be specified or not.) has been initialized.

Syntax

IsEmpty(expression)

The required expression argument (argument: A value that provides information to an action, an event, a method, a property, a function, or a procedure.) is a Variant (Variant data type: The default data type for variables that don't have type-declaration characters when a Deftype statement isn't in effect. A Variant can store numeric, string, date/time, Null, or Empty data.) containing a numeric (numeric expression: Any expression that evaluates to a number. The expression can be any combination of variables, constants, functions, and operators.) or string expression (string expression: An expression that evaluates to a sequence of contiguous characters. Elements of the expression can be: functions that return a string or a string Variant (VarType 8); a string literal, constant, variable, or Variant.). However, because IsEmpty is used to determine if individual variables are initialized, the expression argument is most often a single variable name.

Remarks

IsEmpty returns True if the variable is uninitialized, or is explicitly set to Empty (Empty: The state of an uninitialized Variant variable (which returns a VarType of 0). Not to be confused with Null (a variable state indicating invalid data), variables with zero-length strings (" "), or numeric variables equal zero.); otherwise, it returns False. False is always returned if expression contains more than one variable. IsEmpty only returns meaningful information for variants (Variant data type: The default data type for variables that don't have type-declaration characters when a Deftype statement isn't in effect. A Variant can store numeric, string, date/time, Null, or Empty data.).

Example

 Note   Examples that follow demonstrate the use of this function in a Visual Basic for Applications (VBA) module. For more information about working with VBA, select Developer Reference in the drop-down list next to Search and enter one or more terms in the search box.

This example uses the IsEmpty function to determine whether a variable has been initialized.

Dim MyVar, MyCheck
MyCheck = MyVar    ' Returns True.

MyVar = Null    ' Assign Null.
MyCheck = MyVar    ' Returns False.

MyVar = Empty    ' Assign Empty.
MyCheck = MyVar    ' Returns True.

      
 
 
Applies to:
Access 2007