Record count in filtered continuous form

G

Guest

I have a continuous form that has several filter criteria in the form header.
As the users make changes to the filter criteria, a subroutine develops a
filter string, which is placed in the forms filter property at the end of the
routine (this works great).

In the forms footer, I have a textbox that I fill with the number of records
in the filtered form
control Source: = Count([Limit_id])

This works fine except where the filter returns no records. In this case,
it actually displays the total number of records in the forms unfiltered
recordset. I have tried removing the control source, and replacing that with
a line in the subroutine that uses DCOUNT("Limit_ID", me.RecordSource,
me.filter) to fill the textbox, but that returns the same number as the other
method.

Anybody have any ideas what I am doing wrong?
 
A

Allen Browne

Try:
=[Form].[RecordsetClone].[RecordCount]

In code, that gives you a zero when there are no records. When there are no
records to display and no new records can be added, the form's Detail
section goes completely blank, and it also has a dreadful time trying to
cope with any boxes that are still shown in the Form Header and Form Footer
sections. It is one of the items addressed in:
Incorrect display of data
at:
http://allenbrowne.com/bug-06.html

If this situation arises just because you set the form's AllowAdditions
property to No to prevent new records, you might consider setting the
property back to Yes, and adding this line to the form's Before Insert event
procedure instead:
Cancel = True
 

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