Form filter isn't properly resetting. Help (1 Viewer)

templeowls

Registered User.
Local time
Yesterday, 22:51
Joined
Jun 11, 2019
Messages
156
I previously posted about this issue and I thought it was solved, but I just ran into another issue when I was actively using the filter.

I have a DB of customer complaints and a form that looks at each complaint one at a time. I have a filter that filters down to only complaints based on the customer ID that the user is currently looking at.

The filter works great when first used; it does exactly as its intended. However, when you remove the filter and go to the next complaint and filter down, it filters down to the previous customer that you filtered to.

I attached an example DB to better explain and the exact filter code is below. If you filter the very first entry, you get the two complaints for 'Jerry Baker'. Now when you clear the filter and move to 'John Riley' and filter, it still goes down to 'Jerry Baker'. This is why I didn't realize this issue at first, because I only tested once.

Any idea what's wrong with the code?

Code:
Option Compare Database

Private Sub btnCustomerComplaints_Click()
On Error GoTo btnCustomerComplaints_Click_Err

    Me.Form.Filter = "[CustomerID] = [Forms]![frmComplaints]![CustomerID]"
    Me.Form.FilterOn = True
    Me.Form.Requery
   
btnCustomerComplaints_Click_Exit:
    Exit Sub

btnCustomerComplaints_Click_Err:
    MsgBox Error$
    Resume btnCustomerComplaints_Click_Exit

End Sub

Private Sub btnClearFilters_Click()
    DoCmd.RunCommand acCmdRemoveFilterSort
    DoCmd.SetOrderBy "[ComplaintDate] ASC"
End Sub
 

Attachments

  • Example.accdb
    712 KB · Views: 179

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 22:51
Joined
Oct 29, 2018
Messages
18,792
Does this work?
 

Attachments

  • Example (3).zip
    30 KB · Views: 185

templeowls

Registered User.
Local time
Yesterday, 22:51
Joined
Jun 11, 2019
Messages
156
That did it. Thank you so much!
 

Users who are viewing this thread

Top Bottom