>

FieldSize Method

Applies To

Field Object.

Description

Returns the number of bytes used in the database (rather than in memory) of a Memo or an OLE Object Field object in the Fields collection of a Recordset object.

Syntax

varname = recordset ! field.FieldSize( )

The FieldSize method syntax has these parts.

Part

Description

varname

The name of a Long or Variant variable.

recordset

A variable of an object data type that specifies the Recordset object containing the Fields collection.

field

The name of a Field object whose Type property is set to dbMemo (Memo), dbLongBinary (OLE Object), or the equivalent.


Remarks

Because the size of an OLE Object field or Memo field can exceed 64K, you should assign the value returned by FieldSize to a variable large enough to store a Long variable.

You can use FieldSize with the AppendChunk and GetChunk methods to manipulate large fields.

Note

To determine the size of a Field object (except Memo and Long Binary types), use the Size property.

See Also

AppendChunk Method, GetChunk Method, Size Property, Type Property.

Specifics (Microsoft Access)

The data access FieldSize method is different from the Microsoft Access FieldSize property, which is set in table Design view. The data access FieldSize method returns the number of bytes in a Field object of type Memo data type or OLE Object data type.

You set the Microsoft Access FieldSize property in order to limit the size of a field in a table. The FieldSize property is only available in table Design view. From Visual Basic, use the Size property to set the size of a field in a table.

Example

See the AppendChunk method example.

Example (Microsoft Access)

The following example uses the FieldSize method to return the size in bytes of two fields in an Employees table. The Notes field is Memo data type and the Photo field is Binary data type.


Sub GetFieldSize()
    Dim dbs As Database, rst As Recordset
    Dim fldNotes As Field, fldPhoto As Field
    Dim strSQL As String


    ' Return Database variable pointing to current database.
    Set dbs = CurrentDb
    ' Construct SQL statement to return Notes and Photo fields.
    strSQL = "SELECT Notes, Photo FROM Employees;"
    ' Create dynaset-type Recordset object.
    Set rst = dbs.OpenRecordset(strSQL)
    Set fldNotes = rst.Fields!Notes
    Set fldPhoto = rst.Fields!Photo
    ' Move to first record.
    rst.MoveFirst
    Debug.Print "Size of Notes:"; "    "; "Size of Photo:"
    ' Print sizes of fields for each record in Recordset object.
    Do Until rst.EOF
        Debug.Print fldNotes.FieldSize; "        "; fldPhoto.FieldSize
        rst.MoveNext
    Loop
End Sub