Custom record counter doesn't work with filter

ARK72

New member
Local time
Today, 03:33
Joined
Jul 26, 2012
Messages
6
Hi, I am using a custom record counter in an Access (2007) form and this is what the code looks like:
Private Sub Form_Current()
Dim rst As DAO.Recordset
Dim lngCount As Long
Set rst = Me.RecordsetClone
With rst
.MoveFirst
.MoveLast
lngCount = .RecordCount
End With
Me.txtRecordCounter = "Record " & Me.CurrentRecord & " of " & lngCount

End Sub

It works great until I run a filter (I right-click on field to be filtered and choose "contains"). If the filter produces no data, I receive an error. The error is "Run-time error 3021. No current record." And, when I click on the Debug button, the ".MoveFirst" line of code is highlighted in the VB window. Any ideas as to what I can do to fix this? Please help! Thanks!
 

Users who are viewing this thread

Back
Top Bottom