Access VBA get record count in table

Access VBA to count the number of records in table.  Message box will say how many records are in table.


Dim db As DAO.Database
Set db = CurrentDb
strSQL = "SELECT Table1.* FROM Table1;"
 On Error Resume Next
 db.QueryDefs.Delete "CountList"
 On Error GoTo 0
 Set NewCountList = db.CreateQueryDef("CountList", strSQL)
 Set RstAcct = db.OpenRecordset("CountList")
 x = RstAcct.RecordCount
 If RstAcct.EOF Then
 MsgBox "table is blank"
   msgbox "There are " & x & " number of records"
 End If

Interested in learning new skills?