PDA

View Full Version : Navigating Through a Recordset (Adding a Record Counter)



jason_kelly
02-01-2011, 06:09 PM
Hi There,

I need your help on this one.

I have the following code:



Private Sub cmdFirst_Click()
rs.MoveFirst
End Sub
Private Sub cmdLast_Click()
rs.MoveLast
End Sub
Private Sub cmdNext_Click()
rs.MoveNext

If Not rs.EOF Then
msgbox rs(0)
Else
cmdLast_Click
End If
End Sub
Private Sub cmdPrevious_Click()
rs.MovePrevious

If Not rs.BOF Then
msgbox rs(0)
Else
cmdFirst_Click
End If
End Sub


However, I would like to find out how to add a record counter to the form ie.:
-----------------------------------
Record [X] of [Y]
-----------------------------------

Any help with this is greatly appreciated

Thanks.

Jay. =)

Kenneth Hobs
02-01-2011, 07:21 PM
Use rs.AbsolutePosition and rs.RecordCount. Keep in mind that the first record index is 0.