Field2.GetChunk Method (DAO)

Office 2013 and later

Last modified: March 09, 2015

Applies to: Access 2013 | Office 2013

In this article

Returns all or a portion of the contents of a Memo or Long BinaryField2 object in the Fields collection of a Recordset object.

expression .GetChunk(Offset, Bytes)

expression A variable that represents a Field2 object.




Data Type





The number of bytes to skip before copying begins.




The number of bytes you want to return.

Return Value


The bytes returned by GetChunk are assigned to variable. Use GetChunk to return a portion of the total data value at a time. You can use the AppendChunk method to reassemble the pieces.

If offset is 0, GetChunk begins copying from the first byte of the field.

If numbytes is greater than the number of bytes in the field, GetChunk returns the actual number of remaining bytes in the field.

Note Note

Use a Memo field for text, and put binary data only in Long Binary fields. Doing otherwise will cause undesirable results.

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.

Sub AppendChunkX() 
 Dim dbsNorthwind As Database 
 Dim rstEmployees As Recordset 
 Dim rstEmployees2 As Recordset 
 Set dbsNorthwind = OpenDatabase("Northwind.mdb") 
 ' Open two recordsets from the Employees table. 
 Set rstEmployees = _ 
 dbsNorthwind.OpenRecordset("Employees", _ 
 Set rstEmployees2 = rstEmployees.Clone 
 ' Add a new record to the first Recordset and copy the 
 ' data from a record in the second Recordset. 
 With rstEmployees 
 !FirstName = rstEmployees2!FirstName 
 !LastName = rstEmployees2!LastName 
 CopyLargeField rstEmployees2!Photo, !Photo 
 ' Delete new record because this is a demonstration. 
 .Bookmark = .LastModified 
 End With 
End Sub 
Function CopyLargeField(fldSource As Field2, _ 
 fldDestination As Field2) 
 ' Set size of chunk in bytes. 
 Const conChunkSize = 32768 
 Dim lngOffset As Long 
 Dim lngTotalSize As Long 
 Dim strChunk As String 
 ' Copy the photo from one Recordset to the other in 32K 
 ' chunks until the entire field is copied. 
 lngTotalSize = fldSource.FieldSize 
 Do While lngOffset < lngTotalSize 
 strChunk = fldSource.GetChunk(lngOffset, conChunkSize) 
 fldDestination.AppendChunk strChunk 
 lngOffset = lngOffset + conChunkSize 
End Function