Results 1 to 3 of 3
  1. #1
    Lounger
    Join Date
    Nov 2001
    Location
    Newark, New Jersey, USA
    Posts
    31
    Thanks
    0
    Thanked 0 Times in 0 Posts

    'You cancelled the previous operation' (Access 2002)

    When I use the following code, 2 out of three times, it works fine and filters the form to the field specified, but occasionally I'll get a Run time error 2001: You canceled the previous operation.
    Any thoughts? I'm kind of puzzled as to why it works sometimes, and not others.

    Private Sub cboProjectNumber_AfterUpdate()
    On Error GoTo Err_cboProjectNumber_AfterUpdate
    Dim sql As String
    Dim Fieldname As String
    Dim FieldValue As String
    Fieldname = "PROJECT_NUMBER ="
    FieldValue = cboProjectNumber.Value
    sql = Fieldname & Chr(34) & FieldValue & Chr(34)

    Forms!frmProjectDetail.Filter = sql
    Forms!frmProjectDetail.FilterOn = True

    Exit_cboProjectNumber_AfterUpdate:
    Exit Sub

    Err_cboProjectNumber_AfterUpdate:
    MsgBox Err.Description
    Resume Exit_cboProjectNumber_AfterUpdate

    End Sub

    Thanks in advance for any feedback. This one's been bugging me for a while.

    Rich

  2. #2
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: 'You cancelled the previous operation' (Access 2002)

    I think that sometimes the value of the sql string can't be used for a filter.

    Presumably Project_number is a string. Does it sometimes have unusual characters in it?

    Try adding a msgbox line to inspect the value of sql and see if you can see a pattern in the failures.

    sql = Fieldname & Chr(34) & FieldValue & Chr(34)
    msgbox(sql)
    Forms!frmProjectDetail.Filter = sql
    Regards
    John



  3. #3
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: 'You cancelled the previous operation' (Access 2002)

    You can also get this error when a couple of events collide. For example, if the form is in edit mode when you try to change the filter, you might get this error.
    Charlotte

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •