Sub exaRecordsetDelete()
Dim db As Database
Dim rs As Recordset
Dim DeleteCt As Integer
Set db = CurrentDb
Set rs = db.OpenRecordset("Books Copy")
DeleteCt = 0
rs.MoveFirst
Do While Not rs.EOF
If rs!Price > 20 Then
rs.Delete
DeleteCt = DeleteCt + 1
End If
rs.MoveNext
Loop
rs.Close
Debug.Print Format$(DeleteCt) & " records deleted."
End Sub
|