Record count results not consistent

J

Jenno

I have a form with 2 labels, one for the current record (lblRecCount),
the other for the total records (lblTotRec). I use the following code
after a filter is set to capture the total records:

Me.RecordsetClone.MoveLast
lblTotRec.Caption = Me.RecordsetClone.RecordCount

....and the following code to update the current record each time the
user moves between records:

Private Sub Form_Current()
lblRecCount.Caption = Me.Recordset.AbsolutePosition + 1
End Sub

This works fine on my computer all the time, however, another user with
their own copy of the db gets odd results as they move through the
records. The first record displays as record #2 and the second as
record #1, records 3 onwards are ok until they get to the last 2
records when tranposition reoccurs.

Any thoughts?

Thanks in advance.
 
B

Bob Hairgrove

I have a form with 2 labels, one for the current record (lblRecCount),
the other for the total records (lblTotRec). I use the following code
after a filter is set to capture the total records:

Me.RecordsetClone.MoveLast
lblTotRec.Caption = Me.RecordsetClone.RecordCount

...and the following code to update the current record each time the
user moves between records:

Private Sub Form_Current()
lblRecCount.Caption = Me.Recordset.AbsolutePosition + 1
End Sub

This works fine on my computer all the time, however, another user with
their own copy of the db gets odd results as they move through the
records. The first record displays as record #2 and the second as
record #1, records 3 onwards are ok until they get to the last 2
records when tranposition reoccurs.

Any thoughts?

Thanks in advance.

Do you base the form on a sorted query, or just on the table? You need
to have the former for this to work properly.
 
J

Jenno

Interesting....It is based on the table, not a sorted query and to
modify now would cause me a lot of heartburn!
Any thoughts on why it has always worked ok for me, but does not for my
other user?

Thanks
 
D

Damon Heron

Why not put this in the form's current event, and just use one label
(lblNavigate)? :

Dim lngCount As Long
lngCount = 0
With Me.RecordsetClone
If .RecordCount > 0 Then
If lngCount = 0 Then
.MoveLast
End If
lngCount = .RecordCount
If Me.CurrentRecord > lngCount Then
Me.lblNavigate.Caption = "Record " &
Me.CurrentRecord
Else
Me.lblNavigate.Caption = "Record " &
Me.CurrentRecord & " of " & lngCount
End If
End If
End With

HTH
Damon
 

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