VBA Table Record Count

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is there an easy way to count the records in a table without opening the
table and counting each record some sort of a listfile function the gives you
a count ???, any help would be appreciated.
 
Create a saved query that pulls all the records from your table and then
call the following function.

Public Function GetRecordCount()
Dim rst As DAO.Recordset
Dim lngCount As Long

Set rst = CurrentDb.OpenRecordset("YourQuery")

With rst
.MoveFirst
.MoveLast
lngCount = .RecordCount
End With

Debug.Print "Number of Records = " & lngCount

End Function
 
Is there an easy way to count the records in a table without opening the
table and counting each record some sort of a listfile function the gives you
a count ???, any help would be appreciated.

currentdb.TableDefs("myTablename").RecordCount
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top