Below is my code in QuerySave :TmpInvNo is my textfield
Sub Querysave(Source As Notesuidocument, Continue As Variant)
Dim session As New notessession
Dim db As notesdatabase
Dim view As notesview
Dim doc As notesdocument
Dim curdoc As notesdocument
Dim result As Variant
Dim strRunNo1 As String
Dim strRunNo As String
Set db=session.currentdatabase
Set view = db.GetView("LsvNoLookup")
Set doc = view.GetFirstDocument
If Source.IsNewDoc Then
If doc Is Nothing Then
Call source.FieldSetText ( "TmpLog1", "1")
Else
strRunNo1 =Trim(doc.TmpLog1(0))
strRunNo = Trim(strRunNo1+ 1)
Call source.FieldSetText ( "TmpLog1", strRunNo)
End If
End If
Call Source.Refresh
End Sub
Subject: Please clarify
What are you trying to do? Just posting code, without explaining the background or even what is going wrong is not a good way to get help.
Subject: Generate Unique Document Number
Im sorry coz this my first time post to this forum and im new in lotusscirpt.
Situation :
currently my DB require to have document number that will generate after submit the Form. document number must starting from 30000 and will end 40000. After hit to 40000, it will reset back to 30000.
Problem :
I don’t know how to reset back to minimum number 30000 after hit 40000. Below is my code for generate the number :
Code :
Sub Querysave(Source As Notesuidocument, Continue As Variant)
Dim session As New notessession
Dim db As notesdatabase
Dim view As notesview
Dim doc As notesdocument
Dim curdoc As notesdocument
Dim result As Variant
Dim strRunNo1 As String
Dim strRunNo As String
Set db=session.currentdatabase
Set view = db.GetView("LsvNoLookup")
Set doc = view.GetFirstDocument
If Source.IsNewDoc Then
If doc Is Nothing Then
Call source.FieldSetText ( "TmpLog1", "30000")
Else
strRunNo1 =Trim(doc.TmpLog1(0))
strRunNo = Trim(strRunNo1+ 1)
Call source.FieldSetText ( "TmpLog1", strRunNo)
End If
End If
Call Source.Refresh
End Sub
Subject: try this
Between these 2 lines
strRunNo = Trim(strRunNo1+ 1)
if strrunno >“40000” THEN strrunno=“30000”
Call source.FieldSetText ( “TmpLog1”, strRunNo)
Subject: result after include the code
after I include that code:
If strRunNo >“30003” Then strRunNo=“30000”
→ for testing I put max number 30003 and minimum 30000
Yes it will reset back to number 30000, but after I create 2 more form and submit. It will generate the same number that is minimum number 30000. the number that not increase.
Subject: Well, yes
It won’t be unique any more once you go back to 30000
If you still need it to be unique, you could always a @unique on the, so the numbers would be something like
30000-CBOE-XYZ123
30001-CBOE-XYZ155
30002-CBOE-XYZ238
30000-CBOE-XYZ312
…