How do you run a function AFTER a filter has been applied?

RBetz

New member
Local time
Today, 03:03
Joined
Jun 20, 2008
Messages
5
How do you run a function AFTER a filter has been applied?

The Apply Filter event off the form is run before the filter is applied.
I need a way to run code after the filter is applied.

Any ideas?





... while I'm asking ... how do you run a function after a filter has been removed?
 
Have you looked at the "On Apply Filter" event? I'm guessing the same event fires when you remove a filter, too.

Please let us know back.
 
Thanks for the suggestion.

The "On Apply Filter" event is the Apply Filter event mentioned above.
It is run before the filter is applied.
 
OK, you got me on that.

Could you use that event to set a flag and kick off the form's timer to check the flag some time later (say 1 second later)? Disable the timer when you have done what you want.
 
Have you tried the form's FILTER event (not to be confused with the Apply Filter event)?
 
The Filter event is called when the initial filter is pressed (e.g. Filter By Form or Filter By Selection). I use to set focus to the most commonly filtered field.

I used georgedwilkinson's timer idea although I'm not completely comfortable with it because it's a guess .... in that I assume it will take 1 second for the process to complete but if it takes more then the timer action will happen too soon and if it takes much less then they delay in updating a particular value on the screen is obvious.
For now it works ...

Thanks for you help.
 
I used georgedwilkinson's timer idea although I'm not completely comfortable with it because it's a guess .... in that I assume it will take 1 second for the process to complete but if it takes more then the timer action will happen too soon and if it takes much less then they delay in updating a particular value on the screen is obvious.
For now it works ...

If you use a timer, just use a static integer to avoid re-entrant code:

Code:
Private Sub Form_Timer()
Static AlreadyRunning As Integer
    If AlreadyRunning Then 'Don't run the code if it's already running.
        Exit Sub
    End If
    AlreadyRunning = 1 'Make it so the code won't re-enter.
    DoEvents 'You probably will want to pepper these throughout your code below if you have a long-running loop.

    Call DoStuff 'Perform the actual work you wanted done here.

    AlreadyRunning = 0 'Now it's safe to run the code again.
End Sub

I didn't understand what was the matter with Bob's suggestion to use the Filter event. I never tried either but would like to understand for my own edification.
HTH
 

Users who are viewing this thread

Back
Top Bottom