Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Record Count

Status
Not open for further replies.

chesterex

Technical User
May 23, 2001
4
CA
Is there an easy way to get a record count of a recordset that I already set as an object?

EG
Dim i as Integer
Set dbS = CurrentDb
Set qryBr = dbS.OpenRecordset("FULLReportqry")
i = qryBr.RECORDCOUNT

of course I can not use RECORCOUNT - is there another way?
Thanks
Tim
 
Based on the code above, if FullReportqry is the name of a table in the database, the RecordCount property will contain the number of records in the recordset once opened because DAO will open it as a TypeType recordset.

If FullReportqry is the name of a query (as it appears to be), the recordset will be opened as a DynasetType recordset. In that case the RecordCount property is only applicable to the number of records accessed, so you will need to move to the end of the recordset to fully populate the property, ie:

Set qryBr = dbS.OpenRecordset("FULLReportqry")
qryBr.MoveLast
i = qryBr.RECORDCOUNT Jon Hawkins
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top