ACC: Data Changes Are Saved to the Incorrect RecordID: Q191883
|
Moderate: Requires basic macro, coding, and interoperability skills.
When you make a change to the data in a form record, you find that the
changed data is saved to the wrong record.
This behavior can occur under the following two circumstances:
Sub main()
On Error GoTo ErrorHandler
Dim db As DAO.Database, SQL As String
Dim td As DAO.TableDef, fld As DAO.Field, qd As DAO.QueryDef
Dim rs As DAO.Recordset
Dim bkmk As Variant
Dim nAbsolutePosition As Variant
' Open database with large table.
Set db = DBEngine.OpenDatabase("C:\Northwind.mdb")
Set db = CurrentDb()
' Open a dynaset or snapshot with hundreds of records.
Set rs = _
db.OpenRecordset("SELECT * FROM [Order Details]", _
dbOpenDynaset)
' Populate the table.
rs.Move (1000)
bkmk = rs.Bookmark
' Delete a record.
rs.MoveFirst
rs.Delete
' Go to a bookmark way down the table.
rs.Bookmark = bkmk
' Get the position so you can move back here.
nAbsolutePosition = rs.AbsolutePosition
Debug.Print "Absolute position = " & nAbsolutePosition _
& ": UnitPrice = " & rs![UnitPrice]
' Move to position by moves.
rs.MoveFirst
rs.Move (nAbsolutePosition)
Debug.Print nAbsolutePosition & " moves: UnitPrice = " _
& rs![UnitPrice]
Exit Sub
ErrorHandler:
MsgBox "An error has occurred "
Resume Next
End Sub
To resolve this problem, do one of the following:
Q151261 OFF97: How to Obtain and Install MS Office 97 SR-2
Me.Requery
at the beginning of the AfterUpdate event of the combo box as follows
Sub ComboBoxName_AfterUpdate()
' Add this line to requery the form.
Me.Requery
' The remaining code was generated by the wizard.
' Find the record that matches the control.
Me.RecordsetClone.FindFirst "[Key] = " & Me!ComboBoxName
Me.Bookmark = Me.RecordsetClone.Bookmark
End Sub
Now when you edit data in the found record it will save properly.Q193052 ACC: Find Bookmark Wizard Available for Download on MSL
Q172733 ACC97: Updated Version of Microsoft Jet 3.5 Available on MSL
Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article. This problem no longer occurs in Microsoft Access 97, SR-2
This behavior is dependent upon both the amount of data in each record and the number of records between the record that is deleted and the record that is edited. You may not see this behavior if you have very few records in your table or if you do not search for a record far enough away from the deleted record.
Q100132 ACC: Four Ways to Move to a Record from a Combo Box Selection
Additional query words: pra corruption integrity
Keywords : kbdta FmrProp FmrHowto FmrProb
Version : WINDOWS:2.0,7.0,97
Platform : WINDOWS
Issue type : kbbug
Last Reviewed: July 1, 1999