Label Record x of y

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
 
S

Steve Schapel

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top