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

ID: Q109717


The information in this article applies to:
  • Microsoft Access versions 1.0, 1.1, 2.0, 7.0, 97


SYMPTOMS

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

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:
  1. Open the sample database Northwind.mdb (or NWIND.MDB in versions 1.x and 2.0).


  2. Create the following new function in a module:


  3. 
         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 
  4. 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:


  5. 
          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.


REFERENCES

For more information about snapshots, search the Help Index for snapshots, or ask the Microsoft Access 97 Office Assistant.

Additional query words:

Keywords : kbprg IntpOle
Version : WINDOWS:1.0,1.1,2.0,7.0,97
Platform : WINDOWS
Issue type : kbprb


Last Reviewed: October 20, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.