Link to home
Create AccountLog in
Avatar of advlegals
advlegals

asked on

Access Tabular Form - Row Numbering

I have a tabular form which displays annual data in month blocks.

The form has a sort function on it and I can sort on all months Desc.

I'm trying to add a field onto the form that'll number rows from 1..  Please bear in mind that when the recordset is re-sorted the row numbering needs to remain static, running from 1.. to the bottom of the form.

This, on the face of it, would seem like a simple thing to accomplish. I can return a row number from a click event by using Me. CurrentRecord but I can't assign this to my row counter text box at runtime.
ASKER CERTIFIED SOLUTION
Avatar of DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
What is the SQL of the forms record source. I have a solution but involves few steps. Post your SQL here and identify the default sort field (when the form first opens).

Mike
SOLUTION
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
One gotcha with this:

=DSum( [Field1] , Table1 , [Table1].[id]<=[Forms]![Form1]![id] )

it could be painfully slow with a lot of records and ... if there are any gaps in the auto number, you may not get sequential numbers.

mx
SOLUTION
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
further....
you will have to set glbRowCount = 0 prior to running the query (unless you just started Access mdb).

This could be done from within a sub

Sub StartForm()
glbRowCount = 0
docmd.openform "yourform"
end sub

Scott C


Scott C
SOLUTION
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.