wardokdee
wardokdee

Reputation: 45

Create Sequence Number by year and number that will increase +1

I would like to edit/modify my field based on year and then the sequence number.

Field: Year - 00#

For example, a file is created this year, 2020. So, I would like a filed that is computed by number and will increase +1. The filed will be : 2020-001 , then 2020 - 002 and so on.

Before, I got some code from somebody to generate a sequence number.


Sub Querysave(Source As Notesuidocument, Continue As Variant)
'get total no of documents from the view
'if no documents then seq start with 1
Dim docCount
Dim viewCollection As NotesViewEntryCollection
Dim viewEntry As NotesViewEntry
Dim vNum As Long

If source.IsNewDoc Then
    Set viewCollection = view.AllEntries
    docCount = viewCollection.count
    If doccount = 0 Then
        doccount=1
        Call source.FieldSetText("ReqNo","REQ" & Cstr(Format(docCount,"00000#")))   
    Else
        Set viewEntry = viewCollection.GetLastEntry
        Call source.FieldSetText("ReqNo","REQ" &Cstr(Format(doccount+1,"00000#")))  
    End If
    
End If  
End Sub

Based on that code, how can I edit the "REQ" as per above to be the created year?

Thank you very much for your help.

Upvotes: 1

Views: 144

Answers (1)

Knut Herrmann
Knut Herrmann

Reputation: 30970

You get the current year as string with

CStr(Year(Now))

Replace "REQ" with it.

Upvotes: 2

Related Questions