I have a form that is viewed in split form. The form's Filter On Load property is set to
No because I want it to show all records when opened. I have a button to filter the form based on the current CustomerID. My problem is that when I click on the button, nothing appears to happen. If I click on it a second time, then the filter works. Here is my code:
- Private Sub btnCustomerFilter_Click()
-
Dim strCustomerID As Long
-
strCustomerID = Me.CustomerID
-
-
Form.FilterOn = True
-
Me.Form.Filter = "CustomerID=" & strCustomerID
-
-
End Sub
I'm wondering if I'm doing things in the wrong order causing the filter to be turned on at the wrong time, but I don't know for sure. I have a
Clear Filter button that works fine by turning off the filter. If I clear the filters using this button, and then re-filter with the button listed above, then it works the first time. It only requires the filter button to be clicked twice right after the form loads. I'm sure the solution is simple (they all seem simple when I learn what it is), but I can't figure it out.