calculating primary key programmatically in add new record button

G

Guest

ok i need a way to to calculate a primary key value everytime you add a record starting from 13261. The reason being is that that is the last number in the database for primary keys and it was originally not an autonumber field. So far i think i have to do it on form level in the add record button's click event with a loop and setting the textbox to the calculated value. Anyone have any ideas or suggestions ??
 
J

Jeff Boyce

Drew

First, why do you care what value the autonumber has? Access Autonumbers
are intended for use as unique row identifiers, and usually shouldn't be
displayed.

Next, if you MUST start from 13261, why? What is it about your database
that requires starting from this place.

If you MUST, perhaps because you have child records that use the (now
primary key) as a foreign key, then there may be an easier way that what you
asked for ...

If you append your table's rows to a new empty table, with an autonumber
field, and append your key to the autonumber field, and your other fields to
their respective (new) fields, you should have your autonumbers "set". No
further "handling" required.

Or have I misunderstood...?
 

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