hi everyone!
I need to count records in a sub form based on a query. I used
Forms![mainform].form![subform].RecordsetClone.RecordCount but with out success. Can you help please.
thx in advance
Kenneth.
thx rick
I tried to use dcount & even count. It "worked" but when there are no records, the field is blank and not null. I need to count even 0 records.
thx
Kenenth
Yeah, RickGrimes is 100% on target. First, you need to concentrate on counting the subform's data source (the query). Second, you need to use Dcount or something similar.
In a Module's declaration section:
Public gRecordCount As Long
In the On Current event of the Sub Form:
Dim rst As DAO.Recordset
On Error GoTo Err_RecordCount
Set rst = Me.RecordsetClone
rst.MoveLast
gRecordCount = rst.AbsolutePosition + 1
RecordCount_Continue:
MsgBox gRecordCount
rst.Close
Exit Sub
Err_RecordCount:
gRecordCount = 0
Resume RecordCount_Continue
I'll leave it up to you how to use the gRecordCount.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.