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

Auto ID

P: 3
I am trying to create an auto ID having two parts: first part is the current date (yyyymmdd) and second part is an incremental serial number. The serial number will start from 0001. This serial number will be reset at 0001 on the first day of the next year i.e. 01 January.
Example: 20110101-0001, 20110101-0002, ....... 20120101-0001, 20120101-0002, etc.

How can I do it?
Dec 23 '11 #1
Share this Question
Share on Google+
1 Reply


NeoPa
Expert Mod 15k+
P: 31,308
The following example shows how this may be done :
Expand|Select|Wrap|Line Numbers
  1. intNewNo = CInt(Nz(DMax("Right([IDField], 4)", "[YourTable]", "[IDField] Like '" & Year(Date()) & "*'"), 0)) + 1
Dec 24 '11 #2

Post your reply

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