Occasional run-time error

BeeJayEff

Registered User.
Local time
Today, 02:26
Joined
Sep 10, 2013
Messages
198
I get an intermittent "Run-time error '-2147417848 (80010108)': Method 'Bookmark' of object 'Recordset2' failed" at the Bookmark assignment indicated below.

Code:
Private Sub SearchForItemID_AfterUpdate()
Dim rs As DAO.Recordset

If Not IsNull(SearchForItemID) Then
    Set rs = Me.RecordsetClone
    rs.FindFirst "ItemID=" & SearchForItemID
    If rs.NoMatch Then
        MsgBox "Item " & SearchForItemID & " not found in this Sale Event", vbOKOnly + vbExclamation, gstrAppName
    Else
        Me.Recordset.Bookmark = rs.Bookmark            !<------------------
    End If
    
    rs.Close
    SearchForItemID = Null
End If

End Sub

Usually the code works fine with no error, and even after getting the error, if I try again, it usually works. Is Bookmark a Method, and where did Recordset2 come from ? Any ideas welcome.
 
i think it should be:

Me.Bookmark = rs.Bookmark

you set it in the form on its recordset.
also there is no need to do this. the record pointer moves to the end of file on the Copy of your recordset and not on the form. so your code should be:

If Not IsNull(SearchForItemID) Then
Set rs = Me.RecordsetClone
rs.FindFirst "ItemID=" & SearchForItemID
If rs.NoMatch Then
MsgBox "Item " & SearchForItemID & " not found in this Sale Event", vbOKOnly + vbExclamation, gstrAppName
End If

rs.Close
SearchForItemID = Null
End If
 
Thanks for the response.

It seems that I do need the assignment to Me.Bookmark to locate the required record - this is a Continuous (sub)Form, if that makes any difference. Removing the ".Recordset" did the trick.
 

Users who are viewing this thread

Back
Top Bottom