line numbering uestion

N

nevje

trying to get my head around one particular problem ....

in access2k a form for entering order details - with a subform for
seperate lines of the same order. how do i make each new line start at
say 1 and autonumber itself when another new line is created but then on
the next order the line number is back to 1 to start over?

ive uploaded the basic problem to some space if anyones interested in
looking at it, its likely me misunderstanding the basics.

http://www.doobrie.co.uk/ftp/db1.zip

have zip'd it up, its only about 20kb if you want to see the actual
basic thing im working on properly.
 
A

Albert D. Kallal

You can put the following code in the sub form:

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 ref
has been set..
 
Top