record counting

  • Thread starter Thread starter JohnE
  • Start date Start date
J

JohnE

I am replacing the Access record counting with a textbox in the footer
(txtNumber) and using the following code placed in the forms OnCurrent event.


Dim lngCount As Long
Set rst = Me.Recordset.Clone

If rst.EOF = False Then
With rst
.MoveFirst
.MoveLast
lngCount = .RecordCount
End With
Me.txtNumber = "Record " & Me.txtNumber & " of " & lngCount

Else
Me.txtNumber = "Record 0" & " of 0"

End If

It is Access 97 and the code fails at the Recordset word of the Set rst =
Me.Recordset.Clone line. All of this works in A2k and after. Is there
something else that should be used for Access 97?

Thanks for reviewing.

.... John
 
Do you have a reference to the DAO (Data Access Objects) library set? The
complier won't know anything about Recordset unless you do.
 
Actually, both are correct.
To the OP

The method you are using will really slow your form down. An easier way
would be:

With Me
.txtNumber = .Recordset.Absolute Position & " of " &
..Recorset.RecordCount
End With
 
Actually, both are correct.

For some reason, I didn't think Forms had a Recordset property in 97, just
Recordsetclone. My bad.
 
Much as I hate to argue with Dave, you were correct, George. Forms in Access
97 did not have a Recordset property.

You do need to use the RecordsetClone property in Access 97.
 
Back
Top