• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2333
  • Last Modified:

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?
0
SteveL13
Asked:
SteveL13
1 Solution
 
Jim Dettman (Microsoft MVP/ EE MVE)PresidentCommented:
=DCount("[ID]","tblImportRecords",Me.Filter)

<<Also, would it be in the afterupdate event of the form itself? >>

Not sure what you mean or are looking to do.

Jim.
0
 
mbizupCommented:
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

0
 
peter57rCommented:
In the Form.ApplyFilter event procedure

Me.yourtextboxname = Me.RecordsetClone.RecordCount
0

Featured Post

Restore individual SQL databases with ease

Veeam Explorer for Microsoft SQL Server delivers an easy-to-use, wizard-driven interface for restoring your databases from a backup. No expert SQL background required. Web interface provides a complete view of all available SQL databases to simplify the recovery of lost database

Tackle projects and never again get stuck behind a technical roadblock.
Join Now