Autonumbering a field in form

rahultiwari

Registered User.
Local time
Today, 08:44
Joined
Jan 30, 2005
Messages
21
Hi
I am trying to autonumber a field in a form so that it should have a value of 1 more than the highest value in the field.
I am trying to use the following formula.

DMax("[SAMPLE]","BUGSAMPLE")+1

where sample is the name of the field and bugsample is the name of the table.
but everytime I exit the form. the value in the form field becomes 1 while the value in the table field remians the fine.

What else I can do to fix this problem.
Also I cannot change the field in the table to autonumber as there are a lot of relationship already with that field.
Regards
Rahul
 
Rahul,

If your field is called [Sample] on your form, do the following:

Set Sample's property for Locked = Yes (They shouldn't enter/alter it).

Use the form's BeforeInsert event to assign it:

Me.Sample = Nz(DMax("[SAMPLE]","BUGSAMPLE"), 0) + 1

Wayne
 

Users who are viewing this thread

Back
Top Bottom