How can I have a 'number' field output consecutive numbers in a fo

S

Szavozd

I have a form in access which I would like to add a 'number' (not an
'autonumber') field and I want it to calculate automatically the next
consecutive number (NUMBER IN LAST REGISTRY + 1). How can I do this ???

I really appreciate in advance any help I can get on this!!!

Thank you.
 
J

John Vinson

I have a form in access which I would like to add a 'number' (not an
'autonumber') field and I want it to calculate automatically the next
consecutive number (NUMBER IN LAST REGISTRY + 1). How can I do this ???

I really appreciate in advance any help I can get on this!!!

Thank you.

Use the Form's BeforeInsert event with code like:

Private Sub Form_BeforeInsert(Cancel as Integer)
Me!textboxname = NZ(DMax("[ID]", "[tablename]")) + 1
End Sub

where ID is the name of this field in the table tablename.

John W. Vinson[MVP]
 
Top