Please help! sequential number generator

Hi every one, do u know about the sandbox downloas number generator right? But i’ve got this error when i put the assign button in my own application. I’ve got a lot more mistakes too. Can anyone please help me. I am very new to this. Thanks

Sub Click(Source As Button)

If Not uidoc.editmode Then uidoc.editmode = True

uidoc.document.Number = GenerateSequentialNumber( profileNumberForm_Main$ )

End sub

It says illegal parenthesized generatesequentialnumber when I run it in other apps.

Subject: Re: GenerateSequentialNumber

I haven’t looked at the download you mention, but the problem is that GenerateSequentialNumber is not a built-in function in LotusScript. You have to also copy the function definition, not just the button that calls the function. The function probably also uses a view that you will need to copy.

It sounds like you might need to learn quite a bit more about LotusScript before you attempt this application.

Subject: Another example.

Description: * This code goes in the “Initialize” event of an agent, set to

                    run if documents have been created or modified, and on newly

                    modified documents. The field that is updated is called

                    "number" and is an editable text field. The default value of

                    the "number" field is @If(number = "" ; "TBA" ; number). A

                    hidden view and profile documents are also used.



                    This agent is good up to 99,999 documents that contain the

                    field "number".



                    Code: *

                    Sub Initialize



                    Dim Session As New NotesSession

                    Dim db As NotesDatabase

                    Dim view As NotesView



                    Dim ProfileDoc As NotesDocument

                    Dim doc As NotesDocument

                    Dim item As NotesItem

                    Dim item2 As String

                    Dim Nitem As NotesItem

                    Dim Nitem2 As String

                    Dim num As Integer

                    Dim NumStr As String



                    Dim docnum As Integer

                    Dim TBAnum As Integer

                    Dim initialnum As Integer



                    Set db = Session.CurrentDatabase





                    Set view = db.GetView("HiddenViewName")





                    Set ProfileDoc = db.GetProfileDocument("ProfileDocName")

                    Dim maildoc As NotesDocument

                    Set maildoc = New NotesDocument(db)

                    Dim mailitem As NotesItem

                    Call db.UpdateFTIndex(True)



                    docnum = view.FTSearch("*",0)

                    TBAnum = view.FTSearch("TBA",0)



                    NumStr = ProfileDoc.nextid(0)

                    If NumStr = "" Then

                    initialnum = docnum - TBAnum 

                    num = initialnum

                    Else

                    num = Cint(NumStr)

                    End If



                    ProfileDoc.nextid = Cstr(num)

                    Call ProfileDoc.save(False,False)



                    If TBAnum > 0 Then

                    For i = 1 To TBAnum

                    Set doc = view.GetNthDocument(i)

                    Set item = doc.GetFirstItem("number")

                    item2 = item.text



                    If item2 = "TBA" Then

                    num = num + 1

                    If num < 10 Then

                    newnum = "0000" & Cstr(num)

                    Elseif num < 100 Then

                    newnum = "000" & Cstr(num)

                    Elseif num < 1000 Then

                    newnum = "00" & Cstr(num) 

                    Elseif num < 10000 Then

                    newnum = "0" & Cstr(num)

                    Elseif num < 100000 Then

                    newnum = "0" & Cstr(num)

                    Else

                    newnum = newnum

                    End If



                    doc.number = newnum

                    Call doc.save(False,False)



                    ProfileDoc.nextid =Cstr(num)

                    Call ProfileDoc.save(False,False)

                    End If 

                    Next

                    End If

Subject: RE: Another example.

Thank u every one. Thanks for answering my questions. I’m going to try that man. BT, u’re right man, i need to learn more. Thanks And GOd bl;ess u guyz

Subject: SEQUENTIAL NUMBER GENERATOR…maybe this will help?

Create a view GetNumber with ProjectID filed sorted largest to smallest. It will take last (largest) number and add 1

Formula

@If (@IsNewDoc & @IsDocBeingSaved; @Success;@Return(ProjectId));

Num := @DbColumn(“Notes”:“NoCashe”;“”;“GetNumber”;1);

Num1 := @If(@Iserror(Num) | Num=“”;0;@TextToNumber(@Subset(Num;1)));

NewNum := @Text(Num1+1);

@Right(“0000” + NewNum;4);

ANOTHER METHOD:

@If(@IsNewDoc & @IsDocBeingSaved; @Subset(@DbColumn(“” : “NoCache”; “”

: “”; “RMA Number”; 1); 1) + 1; RMAno)