Run time error 2001 "You canceled the previous operation" error on setting bookmark after requery RRS feed

  • Question

  • The me.bookmark = .bookmark command fails with the run time error 2001 You canceled the previous operation.
    The form is a Datasheet subform. Is this a known problem and is there any way I can resolve this problem?

    Private Sub Form_Timer()

      If Not IsNull(Form_frmReviewOrders.txtPlacerOrderNumber.Value) And Form_frmReviewOrders.txtPlacerOrderNumber.Value <> "" And _
        Form_frmReviewOrders.DeferredTab = 0 Then
        Set rstsubformclone = Me.RecordsetClone
        With rstsubformclone

        .FindFirst "[placerordernumber] = '" & Form_frmReviewOrders.txtPlacerOrderNumber.Value & "'"
     '   MsgBox "placerodernumber=" & .Fields("placerordernumber").Value
        If Not .NoMatch Then
           Me.Bookmark = .Bookmark
        End If
        End With
      End If

    End Sub

    Friday, February 19, 2016 3:34 PM


  • There are a couple of oddities about what you're doing that may (or may not) be causing the problem.

    First, I don't see a declaration of rstsubformclone.  Is that declared at module or global level, or do you not have Option Explicit turned on?  If you don't, you should, and you should have rstsubformclone declared:

        Dim rstsubformclone As DAO.Recordset

    Second, what data type is the field [placerordernumber]?  If its a Number type, remove the single quotes in the .FindFirst criteria argument, and make it:

        .FindFirst "[placerordernumber] = " & Forms!frmReviewOrders!txtPlacerOrderNumber

    Third, and probably not the issue, but it's still not a good idea, you are using the Form_<formname> syntax to refer to the criteria form.  For a number of reasons, this is really not a good idea; it is much more reliable to refer to the form through the Forms collection.  Since you're referring to it repeatedly, I would probably get the reference once, like this:

        Dim frm As Access.Form

        Set frm = Forms!Forms!frmReviewOrders

        If Len((frm!txtPlacerOrderNumber & "") > 0 _
        And frm.DeferredTab = 0 _
            With Me.RecordsetClone
                .FindFirst "[placerordernumber] = '" & frm!txtPlacerOrderNumber & "'"
                If Not .NoMatch Then
                    Me.Bookmark = .Bookmark
                End If
            End With
        End If

        Set frm = Nothing

    Dirk Goldgar, MS Access MVP
    Access tips: www.datagnostics.com/tips.html

    Friday, February 19, 2016 5:42 PM