minimal said:
I'm trying to limit the numbers in primary key to 5 digits. I'd like all
of the primary keys to be at least 5 digits long as well (i.e. 00001,
00002, 00003 . . . 00010). I also want Access to assign the number to a
record as it is entered into the database. It may not necessarily be in
order, but it will be unique. I would appreciate any assistance that you
may provide. Thanks!
Access has a data type called auto number. If you include this in your
table a new number will be assigned for each line added to the table.
I don't think you can limit it to 5 digits though.
From Access help:
Microsoft Access provides the AutoNumber data type to create fields that
automatically enter a unique number when a record is added. Once a
number is generated for a record, it can't be deleted or changed. An
AutoNumber field can generate three kinds of numbers: sequential numbers
that increment by one, random numbers, and Replication ID (also referred
to as GUIDs— globally unique identifiers) numbers. AutoNumbers that
increment by one are the most common kind of AutoNumber and are a good
choice for use as a table's primary key (primary key: One or more fields
(columns) whose values uniquely identify each record in a table. A
primary key cannot allow Null values and must always have a unique
index. A primary key is used to relate a table to foreign keys in other
tables.). Random AutoNumbers will generate a random number that is
unique to each record within the table. Replication ID AutoNumbers are
used in database replication (database replication: The process of
creating two or more special copies (replicas) of an Access database.
Replicas can be synchronized, changes made to data in one replica, or
design changes made in the Design Master, are sent to other replicas.)
to generate unique identifiers for synchronizing replicas (replica: A
copy of a database that is a member of a replica set and can be
synchronized with other replicas in the set. Changes to the data in a
replicated table in one replica are sent and applied to the other
replicas.).
gls858