Link to home
Start Free TrialLog in
Avatar of SteveL13
SteveL13Flag for United States of America

asked on

How show filtered record count in a textbox on a form

I have a textbox on a form which display the total record count in a table.  But I also want to have a textbox on the form that shows the filtered record count on the form.

Here's my default value code for the first textbox.

=DCount("[ID]","tblImportRecords")

But what would the code be for the filtered record count?

Also, would it be in the afterupdate event of the form itself?
ASKER CERTIFIED SOLUTION
Avatar of Jim Dettman (EE MVE)
Jim Dettman (EE MVE)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
To base it on the form's recordset, try this in the Current Event of your form:


Private Sub Form_Current()
      dim rs as DAO.Recordset
      set rs = Me.RecordsetClone
       if rs.RecordCount > 0 then
           rs.MoveLast
       end if
       Me.MyTextboxName = rs.Recordcount
End Sub

Open in new window

In the Form.ApplyFilter event procedure

Me.yourtextboxname = Me.RecordsetClone.RecordCount