A
asset number
i am currently creating a database in MS Access. Its an asset management
system, wherein users input various information pertaining to a certain
company asset. It generates an access number containing the year when the
asset was purchased, a number code to specify what kind of asset is it, and a
unique id, which serves as its primary key. the format looks like this:
yyyyzxxx with y being the year, z as the asset type and x as the primary key.
the primary key is dependent on the year. for example, for the first record,
if the year is 2004, it automatically generates 2004z001. for the next record,
with 2004 still inputted as the year, it generates 2004z002.
my problem is that whenever i try to generate a new asset code, but with a
different input year, for example 2005, the primary key doesnt reset back to
001. it continues on with the count from the previous year. for example,
after entering the two previous records from above, and i entered a new item
with the input year 2005, it generates an asset code 2005z003.
i want this primary key to reset back to 001 if the input year is different
from the previous one. this should be the right format: 2005z001.
how do i create a loop which reads the current input year, and reads the
previous year inputed and checks if the year has changed? if the year has
changed, how can i set the primary key back to 001?
system, wherein users input various information pertaining to a certain
company asset. It generates an access number containing the year when the
asset was purchased, a number code to specify what kind of asset is it, and a
unique id, which serves as its primary key. the format looks like this:
yyyyzxxx with y being the year, z as the asset type and x as the primary key.
the primary key is dependent on the year. for example, for the first record,
if the year is 2004, it automatically generates 2004z001. for the next record,
with 2004 still inputted as the year, it generates 2004z002.
my problem is that whenever i try to generate a new asset code, but with a
different input year, for example 2005, the primary key doesnt reset back to
001. it continues on with the count from the previous year. for example,
after entering the two previous records from above, and i entered a new item
with the input year 2005, it generates an asset code 2005z003.
i want this primary key to reset back to 001 if the input year is different
from the previous one. this should be the right format: 2005z001.
how do i create a loop which reads the current input year, and reads the
previous year inputed and checks if the year has changed? if the year has
changed, how can i set the primary key back to 001?