code to autonumber form ID without using autonumber datatype

R

reservedbcreater

hi i didnt use autonumber for my ID
i want to upon form loading for it to take the table data and find that 20
was the last ID# so then take that # and increment it by 1 and then place
the new number (21) into the ID# field on the form when it opens.
the reason being there is already a large amount of data in the tables and
it cant be changed from number to autonumber when there is data on the
table.
 
S

Steve Schapel

Reservedbcreater,

Actually, it is fairly easy to get your table set up with an AutoNumber
in the place of your existing ID field. All you would need to do is
make a blank copy of your table, add a new field AutoNumber data type to
this new table and remove the existing ID field, and then use an Append
Query to insert the existing data into the new table, preserving the ID
values. If you need more specific help with this, just post back.

Alternatively, you can use the Default Value property of the ID control
on your form, set to the equivalent of...
DMax("[ID]","NameOfYourTable")+1
This assumes it is a single view form. If it's a continuous view form,
it's slightly more complicated, post back for more information :)
 
S

Steve Schapel

Don't worry, Reservedbcreater. It's not you who's doing the abusing in
this case.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top