Record P of Q not quite working properly

G

Guest

This has me confused. I use the following code in several of my forms, in
the Form Current event. It gives me a label showing, for example, Record 31
of 286. It works well except on one of my forms where it always shows Record
1 of 6, regardless of how many records there are. I'm not sure where it is
getting the 6??? . I can fix this by clicking in the detail section of the
form, but only if I click in the 2nd record or higher. Clicking in the first
record has no effect on the counter. What's the easy fix?

Private Sub Form_Current()
With Me.RecordsetClone
.Bookmark = Me.Bookmark
Me!lblRecordPofQ.Caption = "Record " & .AbsolutePosition + 1
& " of " & .RecordCount
End With
End Sub
 
F

fredg

This has me confused. I use the following code in several of my forms, in
the Form Current event. It gives me a label showing, for example, Record 31
of 286. It works well except on one of my forms where it always shows Record
1 of 6, regardless of how many records there are. I'm not sure where it is
getting the 6??? . I can fix this by clicking in the detail section of the
form, but only if I click in the 2nd record or higher. Clicking in the first
record has no effect on the counter. What's the easy fix?

Private Sub Form_Current()
With Me.RecordsetClone
.Bookmark = Me.Bookmark
Me!lblRecordPofQ.Caption = "Record " & .AbsolutePosition + 1
& " of " & .RecordCount

Me!lblRecordPofQ.Caption="Record " & Me.[CurrentRecord] & " of " &
Me.[RecordsetClone].[RecordCount]

End With
End Sub

If you wish you can do this directly in the control source of an
unbound control... not a label.

="Record " & [Forms]![FormName].[CurrentRecord] & " of " &
[Forms]![FormName].[RecordsetClone].[RecordCount]

Note: You cannot use the Me! keyword in an unbound control's control
source. In which case, code the form's current event:
Me.NameOfControl.Requery
so that the count will be correct after a record deletion.
 

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