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

Access- AutoID format

P: 81
Hi All,

I m have stuck in at a place, Where i want to generate a ID something like "CRC-CC-1009-001".Where

CRC-CC- will remain common for all generated id's
1009- system date
001- incremental order number for the system date.

as if date will change it will start count from 001.

How to customize the fomat for AutoID.
Please help me.
Sep 12 '07 #1
Share this Question
Share on Google+
3 Replies


P: 68
I don't think you can customise autonumber, I had the same issue recently. I resolved it by customing the format of the field in the relevant forms and reports, adding in the prefixs that I wanted
Sep 12 '07 #2

P: 81
I don't think you can customise autonumber, I had the same issue recently. I resolved it by customing the format of the field in the relevant forms and reports, adding in the prefixs that I wanted
ok...thanx kevin for your quick response...but how u did it in form....or just give me some idea how should u i go forward in my case.
Sep 12 '07 #3

damonreid
Expert 100+
P: 114
Expand|Select|Wrap|Line Numbers
  1. Private Sub IDCode_AfterUpdate()
  2. Dim strProdCode As String
  3.  
  4.     If Me.NewRecord Then
  5.     strProdCode = Me.IDCode.Value
  6.         ' Increment the IdentNumber field by One, if field is Null, set as 0 then add 1
  7.         Me!IdentNumber = Nz(DMax("Right(Identifier,4)", "IDCodeQuery"), 0) + 1
  8.         Me!Identifier = Me.IDCode.Value & "-" & Format(Me!IdentNumber, "0000")
  9.     Else
  10.          Me!strID = Me!strID
  11.     End If
  12.  
  13. End Sub
This makes a unique number with the pre-field IDCode then a - then the next avilable number in the format 0000.
IDCodeQuery is only used to get the next avilable number because the pre-field code can change. You want the DMax and Right or Left codes to do what you want to do.
Sep 12 '07 #4

Post your reply

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