Returns a string that provides information about a variable.
TypeName(varname)
The varname argument can be any variable except a variable of a user-defined type.
The string returned by TypeName can be any one of the following:
String Returned |
Variable contains |
objecttype |
An OLE Automation object whose type is objecttype. |
Byte |
A byte |
Integer |
An integer. |
Long |
A long integer. |
Single |
A single-precision floating-point number. |
Double |
A double-precision floating-point number. |
Currency |
A currency value. |
Date |
A date. |
String |
A string. |
Boolean |
A Boolean value. |
Error |
An error value. |
Empty |
Uninitialized. |
Null |
No valid data. |
Object |
An object that supports OLE Automation. |
Unknown |
An OLE Automation object whose type is unknown. |
Nothing |
An object variable that doesn’t refer to an object. |
If varname is an array, the returned string can be any one of the possible returned strings (or Variant) with empty parentheses appended. For example, if varname is an array of integers, TypeName returns “Integer()”.
Data Type Summary, IsArray Function, IsDate Function, IsEmpty Function, IsError Function, IsMissing Function, IsNull Function, IsNumeric Function, IsObject Function, Variant Data Type, VarType Function.
This example uses the TypeName function to return information about a variable.
' Declare variables.StrVar As String, IntVar As Integer, CurVar As CurrencyArrayVar (1 To 5) As Integer= Null ' Assign Null value.= TypeName(StrVar) ' Returns "String".= TypeName(IntVar) ' Returns "Integer".= TypeName(CurVar) ' Returns "Currency".= TypeName(NullVar) ' Returns "Null".= TypeName(ArrayVar) ' Returns "Integer()".
The following example creates several object variables and passes them to the TypeName function.
Sub ObjectTypes()dbs As Database, tdf As TableDeffld As Field ' Get current database.dbs = CurrentDb ' Return TableDef object pointing to Orders table.tdf = dbs.TableDefs("Orders") ' Return Field object pointing to OrderDate field.fld = tdf.Fields("OrderDate") ' Print value returned by TypeName for each object..Print TypeName(dbs).Print TypeName(tdf).Print TypeName(fld)Sub