ACC2000: Error "Operation is not supported" with OldValue PropertyID: Q207836
|
When you run code that uses the OldValue property of a control on a form, you may receive the following error message:
Run-time error '3251':
Operation is not supported for this type of object.
Your form is based on an AutoLookup query that is based on more than one
table, and there is a one-to-many relationship between two of the tables.
When you change the data in one field of a record, the Microsoft Jet
database engine saves the entire record, instead of saving only the field
that you modified. When you change the data in any field on the "many" side
of the relationship, the data in the foreign key field is also saved again.
The Microsoft Jet database engine must then requery the fields from the
"one" side of the relationship; this ensures that they contain the data
corresponding to the value that you just saved in the foreign key field.
Once the Microsoft Jet database engine has requeried the field, trying to
access the value of the OldValue property of a control bound to that field results in a run-time error because, at this point, the OldValue property is no longer valid.
Use the RecordsetClone property of the form to retrieve a control's previous value. In the following example, the OnCurrent property of a form is set to an event procedure that creates a recordset; the recordset is a copy of the form's underlying record source. The procedure uses the Bookmark property of the recordset to find the record that corresponds to the current record on the form.
Query: qryAutoLookup
-------------------------------------------------------
Type: Select Query
Join: Categories.[CategoryID] <->; Products.[CategoryID]
Field: ProductID
Table: Products
Field: Product Name
Table: Products
Field: CategoryID
Table: Products
Field: CategoryName
Table: Categories
Dim rs as Recordset
Private Sub Form_Current()
Set rs = Me.RecordsetClone
rs.Bookmark = Me.Bookmark
End Sub
Name: OldCategory
Caption: Old Category Name
Private Sub OldCategory_Click()
MsgBox rs![CategoryName]
End Sub
Name: OldCategoryName
Caption: Old Category Name
Private Sub OldCategory_Click()
MsgBox Me![CategoryName].OldValue
End Sub
Additional query words: run time
Keywords : kberrmsg kbdta FmsProb MdlRcd QryFixup RltOthr
Version : WINDOWS:2000
Platform : WINDOWS
Issue type : kbprb
Last Reviewed: May 13, 1999