Autopopulate ID or Keyword field

  • Thread starter Thread starter Krista
  • Start date Start date
K

Krista

In a database I work with, there are two "ID" fields. One
is the default key field, created by Access. The other is
actually manually numbered...so the user has to go in,
look up the last value entered, and then enter a new
record starting with the next number. I cannot eliminate
the field because it's how they reference entries. I would
like to update the data entry form so it automatically
finds the last manual number and adds the next one when a
new record is created. Possible?
 
Krista,
If the ManulaID entry is truly a number...
In the ManualID field, set the DefaultValue to
DMax("[ManulaID]","tblYourTableName") + 1
When a new record is created, this code will find the maximum number in
ManualID, and add one more to it.
hth
Al Camp
 
Awesome! Made my Monday much easier...thank you VERY much.
-----Original Message-----
Krista,
If the ManulaID entry is truly a number...
In the ManualID field, set the DefaultValue to
DMax("[ManulaID]","tblYourTableName") + 1
When a new record is created, this code will find the maximum number in
ManualID, and add one more to it.
hth
Al Camp

In a database I work with, there are two "ID" fields. One
is the default key field, created by Access. The other is
actually manually numbered...so the user has to go in,
look up the last value entered, and then enter a new
record starting with the next number. I cannot eliminate
the field because it's how they reference entries. I would
like to update the data entry form so it automatically
finds the last manual number and adds the next one when a
new record is created. Possible?


.
 
Awesome! Made my Monday much easier...thank you VERY much.

If this field is in fact numeric, stable, and unique, you might want
to use *it* as the Primary Key (and as the linking field to other
tables), and get rid of Microsoft's autonumber field. Access tries to
give the impression that every table should have an autonumber but
that is emphatically NOT the case! If you have a "natural" key - as it
appears that you do - then no "surrogate" key is needed.

John W. Vinson[MVP]
Join the online Access Chats
Tuesday 11am EDT - Thursday 3:30pm EDT
http://community.compuserve.com/msdevapps
 
John,
I totally agree!! I try to never use Autonumbers. The method I gave to
Krista is one that I've used many times, and have had no trouble with.
Autonumbers are uncontrollable, and unforgiving, and make "archiving"
data a real chore.

Al Camp
 
Back
Top