Adding new record- update Unique ID

M

Mjohnson

I have a table and a form in my database. On my form, I have used the
command button [Add New Record] and it lets me enter my information. I would
like for my ListSeg Field in my table to update every time a new record is
added.

The ListSegs are 4 characters 0001, 0002, 0003, etc and are stored as text.
How do I get it to autogenerate to the next ListSeg when adding a new record.
I don't want for the user to have to type in the List Seg, but for it to
already be there.

Any suggestions would be appreciated
 
K

Klatuu

Make this the Default Value of the control on your form where you want the
ListSeg to be incremented. ListSegTable is a made up name because I don't
know the name of your table, use your own table name here.

=Nz(DMax("[ListSeg]", "ListSegTable"),0) + 1
 
M

Mjohnson

Thanks! That worked great. The only thing that I still need to do is format
the LIstSeg so there is a "0" in front of the newly generated number. Is
there a way I can force the 0 to appear?

Klatuu said:
Make this the Default Value of the control on your form where you want the
ListSeg to be incremented. ListSegTable is a made up name because I don't
know the name of your table, use your own table name here.

=Nz(DMax("[ListSeg]", "ListSegTable"),0) + 1

Mjohnson said:
I have a table and a form in my database. On my form, I have used the
command button [Add New Record] and it lets me enter my information. I would
like for my ListSeg Field in my table to update every time a new record is
added.

The ListSegs are 4 characters 0001, 0002, 0003, etc and are stored as text.
How do I get it to autogenerate to the next ListSeg when adding a new record.
I don't want for the user to have to type in the List Seg, but for it to
already be there.

Any suggestions would be appreciated
 
K

Klatuu

=Format(Nz(DMax("[ListSeg]", "ListSegTable"),0) + 1, "000")

Mjohnson said:
Thanks! That worked great. The only thing that I still need to do is format
the LIstSeg so there is a "0" in front of the newly generated number. Is
there a way I can force the 0 to appear?

Klatuu said:
Make this the Default Value of the control on your form where you want the
ListSeg to be incremented. ListSegTable is a made up name because I don't
know the name of your table, use your own table name here.

=Nz(DMax("[ListSeg]", "ListSegTable"),0) + 1

Mjohnson said:
I have a table and a form in my database. On my form, I have used the
command button [Add New Record] and it lets me enter my information. I would
like for my ListSeg Field in my table to update every time a new record is
added.

The ListSegs are 4 characters 0001, 0002, 0003, etc and are stored as text.
How do I get it to autogenerate to the next ListSeg when adding a new record.
I don't want for the user to have to type in the List Seg, but for it to
already be there.

Any suggestions would be appreciated
 
Top