Type Property (Field Object)

The Type property returns the data type of the Field object. Read-only.

Syntax

objField.Type

Data Type

Integer

Remarks

The Type property contains the data type of the Field object and determines the range of valid values that can be supplied for the Value property. You set the Type property when you first create the field by setting the Class parameter of the Fields collection's Add method. After that, you cannot change the Type property.

Valid data types are as follows:


Type

Description
Decimal value OLE variant type MAPI property type
vbArray Multivalued type 8192 VT_ARRAY PT_MV_FLAG
vbBlob Binary (unknown format) 65 VT_BLOB PT_BINARY
vbBoolean Boolean 11 VT_BOOL PT_BOOLEAN
vbCurrency 8-byte integer (scaled by 10000) 6 VT_CY PT_CURRENCY
vbDataObject Data object 13 VT_UNKNOWN PT_OBJECT
vbDate 8-byte real (date in integer, time in fraction) 7 VT_DATE PT_APPTIME
vbDouble 8-byte real (floating point) 5 VT_R8 PT_DOUBLE,
PT_R8
vbEmpty Not initialized 0 VT_DEREF PT_UNSPECIFIED
vbInteger 2-byte integer 2 VT_I2 PT_I2
PT_SHORT
vbLong 4-byte integer 3 VT_I4 PT_I4,
PT_LONG
vbNull Null (no valid data) 1 VT_NULL PT_NULL
vbSingle 4-byte real (floating point) 4 VT_R4 PT_FLOAT,
PT_R4
vbString String 8 VT_BSTR PT_TSTRING

The current version of CDO does not support the vbNull and vbDataObject data types. The vbEmpty data type should never appear as the value of the Type property because the Add method should derive the data type from the new field's value if the Class parameter is set to vbEmpty.

The vbArray data type must always be used in conjunction with one of the other types, for example vbArray + vbInteger. Note that operations such as comparison cannot be done with a single operator on types involving vbArray.

When you use a multivalued type, to avoid an CdoE_INVALID_TYPE error you must also declare the array to be of the appropriate type, as shown in the following code fragment:

Dim Codes(10) As Long ' NOT just Dim Codes(10) 
' ... 
Set objCodesField = objFieldsColl.Add("Codes", vbArray + vbLong) 
objCodesField.Value = Codes 
 

MAPI stores all custom properties that represent date and time information using Greenwich Mean Time (GMT), also known as Coordinated Universal Time (UTC). CDO converts these properties so that the values appear to the user in local time.

Example

' Fragment from Fields_Add; uses the type "vbString" 
    Set objNewField = objFieldsColl.Add( _ 
                      Name:="Keyword", _ 
                      Class:=vbString, _ 
                      Value:="Peru") 
'  verify that objNewField is a valid Field object 
' Fragment from Field_Type; display the decimal type value 
    MsgBox "Field type = " & objOneField.Type