Creating a record counter in a form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Any thoughts on how to create a record counter in a form, so that it can be
placed in a more specific location than the default (lower left potion of a
form that Access provides)? I'm referring to the counter that is in between
the record selector buttons.
 
All you need to do is to add a control bound to the primary key of the record
(hopefully an autonumber column). The control should have enabled set to
false if it's an autonumber.

Dorian
 
How would this work if the auto number ID has discountinuous numbers? In
other words, if there are any deleted records, this field will not show a
true number count. Also, in the way I'm attempting to make this work, this
would actually be a counter in a subform. So the table might have 100
records, but as it relates to the record on focus in the parent table, there
might only be 3 records. What I want to show is that a person is on record
1, or 2 or 3, in that instance.
 
give this a try, I got it from MS years ago. I use it all the time on forms
and subforms.

Put this function in one of your standard modules as Public.

Function GetXofY(F As Form)

Dim rs As Recordset
On Error Resume Next
Set rs = F.RecordsetClone
rs.MoveLast
rs.Bookmark = F.Bookmark

If (Err <> 0) Then
GetXofY = rs.RecordCount + 1 & " Of " & rs.RecordCount + 1
Else
GetXofY = rs.AbsolutePosition + 1 & " Of " & rs.RecordCount
End If

End Function
Then
Add a textbox usually in the form header or footer and set it’s
Control source to

=GetXofY([Form])
 
Back
Top