473,386 Members | 1,801 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Creating Auto number incorporating the year

I wish to create Auto number (serial number ) in the format which includes the current year i.e., 20130001, 20130002...
And by next it should automatically update the auto number as 20140001, 20140002
How can write code for the above?
Jan 28 '13 #1
2 1335
zmbd
5,501 Expert Mod 4TB
Outright request for code is not allowed - please see the FAQ.

However, as you are still new, if you will post your current efforts, we'll gladly take a look and help you get the code working.

As for this particular topic, a search on this site will turn up several threads covering this exact topic (or at least the concept)... some very recently! :)
Jan 28 '13 #2
NeoPa
32,556 Expert Mod 16PB
As Z says, writing the code for you would break our rules. It would also be pretty hard as you include so little detail in the question. However, I can tell you the concept you will need to understand and implement if you are to do what you want to do.
  1. Determine the common part of the ID. In this case the current year.
  2. Form a filter such that only items matching this are included in the search.
  3. Find the maximum value so far used in the table that matches your criteria.
  4. Extract the sequential numeric portion of the value as a number. Remember to handle the case where none yet exists.
  5. Add 1 to the value from step #4.
  6. Take this number and format into the number of digits required.
  7. Concatenate the result after the Year.
Jan 28 '13 #3

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

Similar topics

2
by: Larry Rekow | last post by:
I am migrating a web application I wrote from ASP to ASP.Net, and from Access to MS SQL server. In the Access version, I did not use the auto number for creating invoices and other documents,...
1
by: Ken | last post by:
Need help on the Auto Number or Identity Seed on the Oracle Database I got an Access database that need to be converted to Oracle 9i. Somehow the Trigger we created to simulate the "AUTO NUMBER"...
5
by: Geoff Cayzer | last post by:
At http://www.blueclaw-db.com/tips_tricks.htm I came across a section which is included below and was hoping for some comment on the article. -------------- Almost never use this auto-number...
16
by: John Baker | last post by:
Hi: I know this is a strange question, but I have inherited a system where files are copied and records re auto numbered (as an index field) )frequently, and I am wondering how high the number...
2
by: Mike N. | last post by:
Hello- I have a database that uses an auto number field type that goes out of sync periodically. My customer gets a "cannot add record, number already in use" error message. I dump the records...
4
by: Shahar | last post by:
Hi I need to get a field name 'ID'(that is an auto-number field) right after I add a new row to table, it's work like that: myCommand.ExecuteNonQuery(); myCommand.CommandText = "SELECT...
13
by: S.Dickson | last post by:
I had an access database that i use as an ordering system. I have a form for entering customer details. When i add a new customer on the form the customer number is an auto number that appears when...
2
by: bubblegirl | last post by:
Hi, I need help in getting this database to work well (user-friendly) by generating auto client ID. The ID is NOT the auto number that Access automatically create when there is no primary key. ...
1
by: bubblegirl | last post by:
Hi there, i am trying to figure out if there is a way to have auto number (not 1,2,3) in access but as a prefix. For example: 1/1/2000 2/1/2000 3/1/2000 the first number as the client...
2
by: Irving Guy | last post by:
Hi all, I’m trying to create a form with 15 fields that generates an auto number in one of those 15 fields. The auto generated number which should display like this – “081-2008-00001”...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.