• Automated Incrementing Field

    Author
    Topic
    #1768385

    At the end of last year I got some help with creating an automated incrementing field. It was working great until it became 2001. The field is supposed to show the letter “E” and then two digits for the year (01) and then the day of the year in three digits, for example today would be 054 because it’s the 54th day of the year, and then the number of the entry using three digits. This is the code I’m using:
    Dim sPrefix As String
    sPrefix = “E” & Format(Date, “yyy”)
    [RefNmbr] = sPrefix & Format(Val(Mid(Nz(DMax(“[RefNmbr]”, “[tblRequests]”, “Left([RefNmbr],6)='” & sPrefix & “‘”), 0), 7)) + 1, “000”)

    It was working fine when the number of the day of the year was three digits, like 256. But now that the year is less than 100 days old it’s not working. For example, the first one for today reads E0154001 which won’t work for incrementing because the day of the year is only showing 2 digits.
    Any suggestions?
    Thanks.

    Viewing 0 reply threads
    Author
    Replies
    • #1779146

      Try this for the sPrefix Line:

      sPrefix = "E" & Format(Date, "yy") & Format(DatePart("y", Date), "000")
      • #1779157

        Thank you so much! It seems to be working now.

    Viewing 0 reply threads
    Reply To: Automated Incrementing Field

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: