Label Record x of y

  • Thread starter Thread starter Marco Simone
  • Start date Start date
M

Marco Simone

I have found on web sites on access tips this code for displaying on label
record x of y instead of Navigation Buttons.

Private Sub Form_Current()
If Me.NewRecord Then
Me!lblNavigate.Caption = "New Record"
Else
With Me.RecordsetClone
.Bookmark = Me.Bookmark
Me!lblNavigate.Caption = "Record " & .CurrentRecord & " of " &
..RecordCount
End With
End If
End Sub

When I open form, Access displays error message: "Run time error 348. Object
doesn't support this property or method." and hihlights this line of code in
VBA:
Me!lblNavigate.Caption = "Record " & .CurrentRecord & " of " & .RecordCount

Does anyone knows why, I am new to VBA.
Thanks for your help, Marco
 
Marco,

There are a couple of errors in the code you are using. Try it like this:

Private Sub Form_Current()
If Me.NewRecord Then
Me!lblNavigate.Caption = "New Record"
Else
With Me.RecordsetClone
.MoveLast
Me!lblNavigate.Caption = "Record " & Me.CurrentRecord & _
" of " & .RecordCount
End With
End If
End Sub
 
Back
Top