Which Event fires AFTER a filter is applied to a Form? (1 Viewer)

ProgAcc

New member
Local time
Today, 22:28
Joined
May 8, 2020
Messages
9
Hello,

I am trying to always show the number of currently displayed records in a label. I have own search and filter subroutines in which I have integrated the count after the Me.Requery. However, I also want to offer the standard filter functionality where this little pop-up window appears and the user can select, all, one, multiple or none of the items in the column. I checked the Me.Filter and see that it indeed changes the Filter String BUT how can I catch it AFTER it is done? Both the Form OnApplyFilter and OnFilter Events are BEFORE the filter is actually applied. So when I do the count inside of these Events it counts the old number of records and then applies the filter.
Also the Form AfterUpdate Event seems to be not triggered by the filter... OnCurrent would be triggered but then the performance is super laggy. Is there really no other way to catch AfterFilter? Thanks for any hints.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 13:28
Joined
Oct 29, 2018
Messages
21,467
Hi. I'm afraid those are the only options available.
 

ProgAcc

New member
Local time
Today, 22:28
Joined
May 8, 2020
Messages
9
But that is such a common use case, how would somebody in practice count and display the records AFTER they have been filtered?
 

theDBguy

I’m here to help
Staff member
Local time
Today, 13:28
Joined
Oct 29, 2018
Messages
21,467
But that is such a common use case, how would somebody in practice count and display the records AFTER they have been filtered?
I just use the Form's Current Event.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 16:28
Joined
Feb 19, 2002
Messages
43,257
1. Filters are the worst method of record selection. If you suspect that you might ever need to convert the BE to SQL Server or some other RDBMS, it is better to use a query with criteria as the recordsource. That is significantly more efficient. If you know you will never have to upsize, then filters are convenient.
2. If you show the navigation bar, the record count shows automatically and you don't need code at all. I don't write code to replicate Access functionality unless the client insists.
3. You can put a count expression in a control in the footer and reference that control from some other control. The footer does't need to be visible.

In a control named RecCoun located in the form's FOOTER:
=Count(*)

In a control named ShowCount located some other place in the detailsection:
=RecCount
 

Isaac

Lifelong Learner
Local time
Today, 13:28
Joined
Mar 14, 2017
Messages
8,777
I almost always just manipulate a form's recordsource rather than using Filters. And, rather than using OpenArgs, when I am able to.
 

ProgAcc

New member
Local time
Today, 22:28
Joined
May 8, 2020
Messages
9
1. Filters are the worst method of record selection. If you suspect that you might ever need to convert the BE to SQL Server or some other RDBMS, it is better to use a query with criteria as the recordsource. That is significantly more efficient. If you know you will never have to upsize, then filters are convenient.
2. If you show the navigation bar, the record count shows automatically and you don't need code at all. I don't write code to replicate Access functionality unless the client insists.
3. You can put a count expression in a control in the footer and reference that control from some other control. The footer does't need to be visible.

In a control named RecCoun located in the form's FOOTER:
=Count(*)

In a control named ShowCount located some other place in the detailsection:
=RecCount


Nice!! Thank you. That is a practical work-around.
 

Users who are viewing this thread

Top Bottom