Filter Record Count

J

Joe

I have a form that I want a message box to pop up showing the number of
records in the dataset after a filter is applied (Filter By Selection, Filter
Excluding Selection, Remove Filter/Sort, etc).

I've added the following code to the form:

Private Sub Form_ApplyFilter(Cancel As Integer, ApplyType As Integer)
MsgBox Me.Recordset.RecordCount
End Sub

Unfortunately, the message box is displaying the number of records in the
form prior to the filter being applied. How can I get a message box to show
the records after the filter is applied?

Example: lets assume that the form is filtered and only 100 or 500 records
are showing. If I right-click and hit Remove Filter/Sort, the message box
pops up and displays "100". I'd like it to display "500", the record count
after the filter change.

I know I'm missing something easy. Thanks in advance for your help!
 
B

Bill

Joe,
I'm not clear where you're invoking the call to Form_ApplyFilter. I have
an application that selects a class of records via a selection list (the
same as clicking on a command button) and the OnClick event sets the
RecordSource filter and issues a Me.Requery. I added your MsgBox
statement immediately after the Me.Requery and get the new record
count without any difficulty. The application is implemented in A2003.
Bill Stanton
 
J

Joe

The Form_ApplyFilter is invoked when I right click on the form and then
select Filter by Selection, Filter Excluding Selection, Remove Filter/Sort,
etc. Each of these essentially results in a filter being applied.
 
B

Bill

I assume then that you have some code that essentially looks like

Me.Filter = some_expression
Me.Requery
MsgBox MsgBox Me.Recordset.RecordCount

I don't see that in your Sub, but your "right-click" popup menu
would necessarily take your code on a path that would include
these statements?

Bill Stanton
 
J

Jan Baird

Jan Baird is out of the country until September 20. Every effort will be
made to respond to messages, but please be patient.
 
J

Jan Baird

Jan Baird is out of the country until September 20. Every effort will be
made to respond to messages, but please be patient.
 
J

Jan Baird

Jan Baird is out of the country until September 20. Every effort will be
made to respond to messages, but please be patient.
 
J

Jan Baird

Jan Baird is out of the country until September 20. Every effort will be
made to respond to messages, but please be patient.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top