Field2.FieldSize Property
Access Developer Reference |
Returns the number of bytes used in the database (rather than in memory) of a Memo or Long Binary Field2 object in the Fields collection of a Recordset object.
Syntax
expression.FieldSize
expression A variable that represents a Field2 object.
Remarks
You can use FieldSize with the AppendChunk and GetChunk methods to manipulate large fields.
Because the size of a Long Binary or Memo field can exceed 64K, you should assign the value returned by FieldSize to a variable large enough to store a Long variable.
To determine the size of a Field2 object other than Memo and Long Binary types, use the Size property.
- If the database server or ODBC driver does not support server-side cursors.
- If you are using the ODBC cursor library (that is, the DefaultCursorDriver property is set to dbUseODBC, or to dbUseDefault when the server does not support server-side cursors).
- If you are using a cursorless query (that is, the DefaultCursorDriver property is set to dbUseNoCursor).
The FieldSize property and the VBA Len() or LenB() functions may return different values as the length of the same string. Strings are stored in a Microsoft Access database in multi-byte character set (MBCS) form, but exposed through VBA in Unicode format. As a result, the Len() function will always return the number of characters, LenB will always return the number of characters X 2 (Unicode uses two bytes for each character), but FieldSize will return some value in between if the string has any MBCS characters. For example, given a string consisting of three normal characters and two MBCS characters, Len() will return 5, LenB() will return 10, and FieldSize will return 7, the sum of 1 for each normal character and 2 for each MBCS character.
Example
This example uses the FieldSize property to list the number of bytes used by the Memo and Long Binary Field objects in two different tables.
Visual Basic for Applications |
---|
|
This example uses the AppendChunk and GetChunk methods to fill an OLE object field with data from another record, 32K at a time. In a real application, one might use a procedure like this to copy an employee record (including the employee's photo) from one table to another. In this example, the record is simply being copied back to same table. Note that all the chunk manipulation takes place within a single AddNew-Update sequence.
Visual Basic for Applications |
---|
|