gojets1721
Registered User.
- Local time
- Today, 05:07
- Joined
- Jun 11, 2019
- Messages
- 429
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?
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