Numbering rows in a subform

S

Sarah

I know I've seen this before, but I can't find the reference.

What is a good way to dynamically number the rows of a continuous subform.
I sort this form on various fields, and I need the numbering to readjust to
1,2,3... after each sort.

thanks much
 
J

Jeff Boyce

Sarah

If the numbering can readjust after each sort, what "value" is it providing?
That is, why do you have the numbers, if they don't stay attached to the
same rows?

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
S

Sarah

Well, 2 reasons really:
1) each record represents an athlete in a competition. An unbound combo box
is used to select a competing group which then displays in the subform. It
is important to keep an eye on the sizes of groups. (The speed of the
competition is determined by the largest, ie slowest, group. I know I could
just have a txtbox displaying the count, but...
2) I'm new at working code and I was just trying to learn how to do this :)
 
S

Stephen Lebans

See:
http://www.lebans.com/rownumber.htm
Rownumber.zip is a database containing functions for the automatic row
numbering of Forms, SubForms and Queries.

Updated Oct. 13 by Allen Browne. Includes error handling and cleaned code.



Here's an update to the Serialize function by Peter Schroeder:

Good to hear. FWIW, here's the version I came up with today, based off of
your code and Ken's(Getz) suggestion, with a few changes:


Function Serialize(qryname As String, keyname As String, keyvalue) As Long

Dim rs As Recordset


On Error GoTo Err_Serialize

Set rs = CurrentDb.OpenRecordset(qryname, dbOpenDynaset, dbReadOnly)

rs.FindFirst Application.BuildCriteria(keyname, rs.Fields(keyname).Type,
keyvalue)

Serialize = Nz(rs.AbsolutePosition, -1) + 1


Err_Serialize:

rs.Close

Set rs = Nothing

End Function


Peter Schroeder


--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
Top