View Full Version : Showing Record Count (Not record selectors) on a form


Graham T
11-05-2001, 03:20 AM
I found the following code on an earlier forum post to show record count without using the default Access record selectors.

I have applied this to a number of forms and it works fine, apart from one minor point and I am wondering if this can be rectified.

The code used is as follows:

________________________________________________

Private Sub Form_Current()

'Show record Count of records displayed in form
'Uses 2 text boxes, Records and RecordNumber.

If Me.NewRecord Then
Me.RecordNumber = " "
Me.Records = " "
Else
Me.RecordNumber = Me.CurrentRecord
Me.Records = "of " & Me.RecordsetClone.RecordCount
End If

End Sub

________________________________________________

When opening the form for the first time the record count displays 1 of 1, however this should for example display 1 of 50. Once you use the forward button and then back it will show the correct count.

Can anything be amended to display the correct record count.

Thanks

chrismcbride
11-05-2001, 09:07 AM
Try poplulating the RecordsetClone property in the Activate event of the form using...

Me.RecordsetClone.MoveLast
Me.RecordsetClone.MoveFirst

The MoveLast method will populate the recordset and MoveFirst brings you back to the beginning (assuming this is where you want to be)...
Chris

Graham T
11-05-2001, 09:24 AM
Thanks Chris

Did the job nicely.