add record number to continuous form

C

CuriousMark

How do I code for a text box on a continuous form that lists the record
number (or row number) of the corresponding record?
 
S

Stuart McCall

CuriousMark said:
Thanks Tony. The list shows the results of a query, sorted by date
ascending.
I am not showing the autonumber field. I want to add a column to the left
that numbers each record in order, from 1 to n, where n is the number of
records returned by the query. Basically, a numbered list.
<snip>

You could give this a try:

http://www.smccall.demon.co.uk/Downloads.htm#LineRenum

It's worked reliably for years for things like order or invoice item lines.
 
A

Albert D. Kallal

CuriousMark said:
How do I code for a text box on a continuous form that lists the record
number (or row number) of the corresponding record?

You can put the follwing code in the orm:

Function Rpos(vId As Variant) As Long

Rpos = 0
If IsNull(vId) = False Then
Me.RecordsetClone.FindFirst "id = " & vId
If Me.RecordsetClone.NoMatch = False Then
Rpos = Me.RecordsetClone.AbsolutePosition + 1
End If
End If

End Function

Then, you can put a un-bound text box in the continoues form,and

=(rpos([id]))

The above assumes you have a key field called id. It also assumes dao.
 
C

CuriousMark

Worked perfectly. Thanks.

Albert D. Kallal said:
CuriousMark said:
How do I code for a text box on a continuous form that lists the record
number (or row number) of the corresponding record?

You can put the follwing code in the orm:

Function Rpos(vId As Variant) As Long

Rpos = 0
If IsNull(vId) = False Then
Me.RecordsetClone.FindFirst "id = " & vId
If Me.RecordsetClone.NoMatch = False Then
Rpos = Me.RecordsetClone.AbsolutePosition + 1
End If
End If

End Function

Then, you can put a un-bound text box in the continoues form,and

=(rpos([id]))

The above assumes you have a key field called id. It also assumes dao.
 
C

CuriousMark

Thanks. A bit more involved than I was hoping for, and the other solution
worked as well.
 

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