autonumber in form

sapowel

New member
Local time
Today, 08:38
Joined
Oct 23, 2001
Messages
6
i have a from that has a subform and the subform is a continuous form. I want to be able to number each item in my subform. I dont need to store the number it would be nice but it is not necessary. Any help would be appriciated. Thank you Scott
 
Being a subform that you are adding to, I would presume that you have a separate table to feed it. If not, how are you doing it?

If you are using a separate table, you should be able to just add an autonumber to the table that is feeding the subform.
 
that would work but i am trying to start over a 1 on the next subform, all i need is for access to number every new entry in the subform and then when i open another form i want it to start over a 1 again.
 
Hello I had a very similar problem like this: maybe you can modify this code to work for you:

Private Sub Form_BeforeInsert(Cancel As Integer)
On Error GoTo Form_BeforeInsert_Err

' Set Line No to "Max" + 1
Forms![Quotation].Form![QuotationProducts]![Item] = DMax("[Item]", "Products", "
=" & Forms![Quotation]!
) + 1

If (IsNull(Forms![Quotation].Form![QuotationProducts]![Item])) Then

' If result was Null (this is the first line), set to 1
Forms![Quotation].Form![QuotationProducts]![Item] = 1

End If

Form_BeforeInsert_Exit:
Exit Sub

Form_BeforeInsert_Err:
MsgBox Error$
Resume Form_BeforeInsert_Exit

End Sub

I had a form that required the item number to reset on each new quote to a customer, this will keep adding 1 to item number until the the quote number changes then it will reset to 1, hope it helps you

Mike

[This message has been edited by Xenix (edited 11-06-2001).]
 

Users who are viewing this thread

Back
Top Bottom