• Filtering Causing Weird Behavior

    Author
    Topic
    #461658

    The screenshot shows a text box labeld with “Find”. The name of the text box is “txtFind”.
    The following subprocedure is assgined to the On Exit event of the text box.
    Private Sub txtFind_Exit(Cancel As Integer)
    Me.Filter = “[BookTitle] like ‘*” & [txtFind] & “*'”
    Me.OrderBy = “BookTitle”
    Me.FilterOn = True
    End Sub

    Yes, after entering, say, “Introduction”, indeed Access succeeds to display only records with “Introduction” in the BookTitle field. Then all the nighmares start to show up. Pressing all other buttons shown in the screenshot has not effect. Especially for the “All” button, it is assigned the following subprocedures:
    Private Sub CmdAll_Click()
    Me.OrderBy = “BookTitle”
    Me.OrderByOn = True
    Me.FilterOn = False
    End Sub

    But why?

    In addition, whenever scrolling several pages down and clicking a record, the form always scroll back to the first record. It appear a Requery is executed.

    But why?

    Please help. Thanks.

    Armstrong

    Viewing 0 reply threads
    Author
    Replies
    • #1172181

      After assigning the same subprocedure to the After Update event of the [txtFind]. All problems are gone. But why?
      Thanks.
      Armstrong

      • #1172189

        We have too little information to know why, but it’s probably because the On Exit procedure occurs each time the focus leaves the text box, whether the contents have changed or not, so filtering occurs too often.

    Viewing 0 reply threads
    Reply To: Filtering Causing Weird Behavior

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: