Creating a record counter in a form

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.
 
G

Guest

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
 
G

Guest

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.
 
G

Guest

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])
 

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