Results 1 to 2 of 2
  1. #1
    HarryScofs is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2011
    Posts
    16

    Creating a Custom Autonumber with year and letters

    I need to create two different custom autonumber fields. Both need the first two characters to be the last two character of the current year. For, Example for this year it would be 11_ _ _.

    For the first field called project number the next three characters need to be numbers starting with 001. The Second field called bid numbers needs to be two letters starting with AA.

    The numbers should flow like this:

    11001
    11002
    12001



    and

    11AA
    11AB
    12AA

    Thanks
    11AB

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,598
    Requires VBA to create and control customized unique ID. I do something similar to create ID like 2011A-0001. Sequential numbering is easy, sequential alpha I have never attempted. This is example from my project:
    Code:
    Dim strLabNum As String
    DoCmd.SetWarnings False
    'search for aborted lab number and use that record, else if none then create new record
    strLabNum = Nz(DLookup("LabNum", "Submit", "IsNull(DateEnter)"), "")
    If strLabNum <> "" Then
    DoCmd.RunSQL "UPDATE Submit SET DateEnter=#" & Date & "# WHERE LabNum='" & strLabNum & "'"
    Else
    strLabNum = Nz(DMax("LabNum", "Submit"), "")
    If strLabNum = "" Then
    'this accommodates very first generated number of blank database
    strLabNum = Year(Date) & "A-0001"
    Else
    'this accommodates change in year
    If Left(strLabNum, 4) = CStr(Year(Date)) Then
    strLabNum = Left(strLabNum, 6) & Format(Right(strLabNum, 4) + 1, "0000")
    Else
    strLabNum = Year(Date) & "A-0001"
    End If
    End If
    DoCmd.RunSQL "INSERT INTO Submit(LabNum, DateEnter, EnterWho) VALUES('" & strLabNum & "', #" & Date & "#, '" & Form_Menu.tbxUser & "')"
    End If
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Creating Custom Fields
    By RudeRam in forum Queries
    Replies: 3
    Last Post: 08-01-2011, 01:09 PM
  2. creating custom switchboard
    By cnstarz in forum Forms
    Replies: 0
    Last Post: 05-25-2011, 12:18 AM
  3. How to make a custom autonumber?
    By AccessThis in forum Access
    Replies: 1
    Last Post: 07-20-2010, 06:49 PM
  4. Creating Custom Ribbons
    By disco_stu in forum Access
    Replies: 1
    Last Post: 07-13-2010, 06:10 PM
  5. Custom Letters with Grouped Information
    By coolxten in forum Access
    Replies: 2
    Last Post: 05-10-2010, 10:59 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums