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
 
Back
Top