Applying filters using VBA when "Apply Filter" button is NOT pressed.
Posted on 2003-12-10
I am trying to filter the data on a form using the filter by form method, but I want to either have a button on the form to apply the filter, or apply the filter when the filter is closed. I want to have the menu option disabled for filtering.
Here is some current code that I have...
Private Sub Form_Open(Cancel As Integer)
here is the code I am trying to implement, with error
Private Sub Form_ApplyFilter(Cancel As Integer, ApplyType As Integer)
If ApplyType = acCloseFilterWindow then
error message - error 2046
The command or action "Apply Filter/Sort" isn't available now.
In general, I have not been able to have command buttons on such forms, because the filter-by-form method disables the command buttons. (A slight work-around - set the visible property of the cmd button to false, activate the filter by form, then set visible to true - unfortunately, button events still do not work.)
The FormFilter opens correctly, but when the filter is closed, the Filter property is still null.