Need help counting records displayed

  • Thread starter Thread starter TheOneGman
  • Start date Start date
T

TheOneGman

Guest
I've been trying to count the number of records that display on a subform with little luck. Right now I can count the number of records on the main form by counting the number of records listed in the listbox (using .ListCount). Once I select the subform, I can't seem to count the number of fields displayed since I'm no longer using a listbox to display the records in the subform (I'm just generating rows that are being read directly from the database).
I've tried using DLookUp and have had a little success, I can get the count from the database but once I start using the search fields on the form to narrow searches, the correct number no longer appears since it's not counting the actual records displayed on the screen but the number of records from my database that match the criteria from my clauses.

Ex.
=DLookUp("ID", "SomeForm", "ID = Me.txtID") -- Will work to count to actual number of times that ID occurs in my DB, but won't display the correct count when say I further define the search to find people with the FirstName Mike with the same ID. (10 ppl exist with that ID but only one record is displayed on the subform with that ID and the Name Mike)

Heh, not sure if that all makes sense or not. I'd apperciate any help. Thanks
 
Dim lngRecCnt as Long
....
lngRecCnt = Forms("MyMainFormName")("MySubFrmCntlName").Form.RecordsetClone.RecordCount
...

hth,
 
Last edited:
Dim lngRecCnt as Long
....
lngRecCnt = Forms("MyMainFormName")("MySubFrmCntlName").Form.RecordsetClone.RecordCount
...

hth,


Let's pretend I'm brand new to access. I don't have a subform in my request for help. I have a query and a report. Where would I put the above suggestion?
 
dcount("*","somequeryname") will give the number of items - you don't need specifically to refer to the subform.
 
Is there a way to only count unique values. There are duplicates and I only want them counted as 1.
 
design a query, set for "distinct values"

then dcount("*", "mydisctinctvaluequery")
 

Users who are viewing this thread

Back
Top Bottom