Results 1 to 5 of 5
  1. #1
    JesseD is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2011
    Posts
    2

    Generating a sequential number based on the date entered

    I am looking to create an access 2010 data base where each entry is generated from a user completed form. Once the form is completed I need to create a unique, sequential number based on the date of entry.



    For example: The first entry submitted between 6/1/2011-5/31/2012 would need to be "01-001". The second submitted in this time frame would be "01-002"
    The first entry submitted between 6/1/2012-5/31/2013 would be "02-001", and so on.

    Any help/suggestions would be greatly appreciated.

  2. #2
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722
    Just saw your post and my initial thought is Why do you need this particular format?
    Just curious.

  3. #3
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    I'm with orange this is an odd request.

    Are you storing your dates as dates (for instance a starting date and closing date) or is it a text string? how do you know all of your data entry is going to be accurate if it's not two date fields? because 01/01/2011 would not equal 1/1/2011, etc.

  4. #4
    JesseD is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2011
    Posts
    2
    We number our orders based on the fiscal year of which they were received.

  5. #5
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    Ok so you're looking at the invoice creation date

    so your FY begins on 6/1 and ends on 5/31 so fy11 would go from 6/1/2010 through 5/31/2011?

    If so you could (on your data entry form) populate the field you're interested in with something like

    Code:
    Dim fy As Integer
    Dim RecCt As Long
    
    If DatePart("m", [PODATE]) >= 6 Then
        fy = Right(DatePart("yyyy", [PODATE]), 2) + 1
    Else
        fy = Right(DatePart("yyyy", [PODATE]), 2)
    End If
    
    RecCt = DCount("[POID]", "Tbl_POs", "[PODATE] between #" & CDate("6/1/" & fy - 1) & "# AND #" & CDate("5/31/" & fy) & "#")
    
    If RecCt = 0 Then
        poid = fy & "-001"
    Else
        poid = fy & "-" & Right("00" & RecCt + 1, 2)
    End If
    You'd have to substitute in your table name and field name but this works for me.

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

Similar Threads

  1. Replies: 13
    Last Post: 12-05-2011, 05:10 AM
  2. Sequential number on subform
    By jpkeller55 in forum Access
    Replies: 8
    Last Post: 03-17-2011, 09:54 AM
  3. Adding record with next sequential number
    By stanley721 in forum Forms
    Replies: 3
    Last Post: 02-28-2011, 01:26 PM
  4. Assign A Sequential Number To A Table Row
    By KramerJ in forum Programming
    Replies: 11
    Last Post: 04-08-2009, 08:48 AM
  5. Replies: 1
    Last Post: 01-31-2009, 10:43 AM

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