Microsoft KB Archive/109717

= ACC: Memo and OLE Fields in a Snapshot Are Not Static =

Article ID: 109717

Article Last Modified on 1/18/2007

-

APPLIES TO


 * Microsoft Access 1.0 Standard Edition
 * Microsoft Access 1.1 Standard Edition
 * Microsoft Access 2.0 Standard Edition
 * Microsoft Access 95 Standard Edition
 * Microsoft Access 97 Standard Edition

-



This article was previously published under Q109717



Advanced: Requires expert coding, interoperability, and multiuser skills.



SYMPTOMS
Data in a snapshot that includes a Memo or OLE field can be changed if the data in the underlying table for the snapshot changes.

This article assumes that you are familiar with Visual Basic for Applications and with creating Microsoft Access applications using the programming tools provided with Microsoft Access. For more information about Visual Basic for Applications, please refer to your version of the "Building Applications with Microsoft Access" manual.

NOTE: Visual Basic for Applications is called Access Basic in Microsoft Access versions 1.x and 2.0. For more information about Access Basic, please refer to the "Introduction to Programming" manual in Microsoft Access version 1.x or the "Building Applications" manual in Microsoft Access version 2.0



CAUSE
Microsoft Access stores the contents of Memo and OLE fields differently than other data types. Memo and OLE field data is not stored in the data page holding the actual record. Instead, the data page holding the record has an address pointer that specifies the data page(s) that contain the data.

When you create a snapshot, a static copy of the data page holding the record is copied. This copy contains only the address of the Memo or OLE information. If the actual Memo or OLE information is changed, the snapshot will look to the same data page and will find the changed information.



STATUS
This behavior is by design. To avoid performance degradation, the actual Memo or OLE information is not loaded into the snapshot.



MORE INFORMATION
A snapshot is a copy of the record source data at the time when the snapshot was created. Unlike the data in a dynaset, snapshot data is not linked to data in the underlying tables. The snapshot data does not change as its underlying tables change.

Steps to Reproduce Behavior
You can use the following sample function to demonstrate that a Memo field in a snapshot can be changed:  Open the sample database Northwind.mdb (or NWIND.MDB in versions 1.x and 2.0).  Create the following new function in a module: Public Function TestSnapshot Dim SS As Recordset Dim DS As Recordset Dim DB As Database

Set DB = CurrentDb

' Create a snapshot and recordset of the Categories table. Set SS = DB.OpenRecordset("Categories", dbOpenSnapshot) Set DS = DB.OpenRecordset("Categories", dbOpenDynaset)

' Move to the first record. SS.MoveFirst DS.MoveFirst

' Print the contents of the CategoryName and Description ' .. fields from both record sets. CategoryName is a        ' .. Text field and Description is a Memo field. Debug.Print Debug.Print "Snapshot:" Debug.Print "  CategoryName: " & SS![CategoryName]

' NOTE: In versions 1.x and 2.0, type a space in the Category ' field name.

Debug.Print "  Description: " & SS![Description] Debug.Print "Dynaset:" Debug.Print "  CategoryName: " & DS![CategoryName] Debug.Print "  Description: " & DS![Description]

' Alter the Description and CategoryName fields using ' ... the dynaset. DS.Edit DS![Description] = "My Description" DS![CategoryName] = "My Category" DS.Update

' Print the new contents of the recordsets. Debug.Print Debug.Print "Snapshot:" Debug.Print "  CategoryName: " & SS![CategoryName] Debug.Print "  Description: " & SS![Description] Debug.Print "Dynaset:" Debug.Print "  CategoryName: " & DS![CategoryName] Debug.Print "  Description: " & DS![Description] End Function   Type the following line in the Debug window (or Immediate window in versions 1.x and 2.0), and then press ENTER:

? TestSnapShot

Note that the following text is displayed in the Debug window:      Snapshot: Category Name: Beverages Description: Soft drinks, coffees, teas, beer, and ale Dynaset: Category Name: Beverages Description: Soft drinks, coffees, teas, beer, and ale

Snapshot: Category Name: Beverages Description: My Description Dynaset: Category Name: My Category Description: My Description 

Note that the second Description for the snapshot reads "My Description," which is the same as the change made by the dynaset. Note also that the second CategoryName for the snapshot is unchanged because Text fields are static in a snapshot.

