By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,738 Members | 1,682 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,738 IT Pros & Developers. It's quick & easy.

Auto incrementing

P: 3
I am trying to design a database that will automatically enter a unique ID for a field that would look like 07-001, (the first 2 digits are the year, a dash, followed by a 3 digit number that auto increases from Jan 1 till Dec 31), then resetting to 08-001 at the beginning of the next year etc.

Does this even make sense?
Feb 26 '07 #1
Share this Question
Share on Google+
3 Replies


100+
P: 1,646
Hi Cynthia. This is not too difficult. You have to do this yourself in code when you want to add another record to the database. Create the value as you have indicated and store it in the uniqueID field.
Feb 26 '07 #2

AccessIdiot
100+
P: 493
An alternative (although maybe cumbersome) way I've done in SQL uses a table to hold values that auto increment and then concatenate them into a final field that you would then use.

The year I supposed you could pull off the computer clock and then snip it, or change the value in the table yourself since it only changes once a year. The next number could be auto incremented and then concatenated, making "1" into "001" etc.

hope this helps!
Feb 26 '07 #3

NeoPa
Expert Mod 15k+
P: 31,769
You could append after the Year value, another value found by adding 1 to a DMax() value of the existing records in the table.
Feb 28 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.