Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Autonumber field

Autonumber field

Autonumber field

I need to create a 5 digit autonumber field for document tracking. Does anyone have any suggestions on the best way to go about this? It is needed to assign a document number to each document so it can be easily tracked. I look forward to any suggestions.

RE: Autonumber field

Does the identifier have to be 5 digit only?  The reason for asking is that there is a built-in @Unique function that is designed specifically for what you're after.

RE: Autonumber field

Yes it has to 5 characters in length. I have tried the @Unique function but is has more than 5 characters.

RE: Autonumber field

I assume you are using this form only to create documents numbered consecutively and that you need to number no higher than 99999.
Create a view of the documents consisting of one column --  the id numbers. On postopen  event open the view above. Use Method "GetLastDocument" of NotesViewClass. Get the id field from that last document and increment it and fill the id field on the new document with that number. If you have to have leading zeros you will need to create a function called here to input them. When the document is saved it will then have the next id number in sequence. You could also do this on the QuerySave event but the user would never see the number. If you need to create more than 99999 documents the called function will need to be a little more complicated because you will be using a text value rather than a number.

RE: Autonumber field

u can use a profile field for automatic number generation....
this has to be used with the setprofilefield and get profile field functions....
if interested i can send u the details


RE: Autonumber field

Yes, I am interested and would appreciate anything you could send me on this. Thank you.

RE: Autonumber field


Just the question I was about to ask. I like the @Unique function, but it also does not fit my needs exactly. I need a unique identifier for each document. Much like you described above. Please let me know how I might do the following... if it differs from above.

1) Upon opening a new form... assign it a unique id.
2) Numerical values only.
3) Auto increment.

Any detailed instructions would be greatly appreciated.


RE: Autonumber field

create a profile form. there you keep in a field the value of the counter for the last document created. in the form of the documents you have to handle, put a field "computed when composed" with the default value "@getProfileField(...)  

email me for details....

RE: Autonumber field

If you are running this from the server the GetProfileField(..) works for a while and then you start getting random values from the Profile Field.  The only way to clear it and get back to the correct values is to run Drop ALL on the server.  We discussed this problem with Lotus and they told us that the Profile Document is designed for Write Once and Read Many Times.  I haven't tried it on a local client.


RE: Autonumber field

i use this method on a few databases since november 2001  but so far i got no errors...

RE: Autonumber field


Tried to find an e-mail address to get more detailed instructions, but couldn't find one. I'd like to get your help on this issue.

Thanks in advance,


RE: Autonumber field

I picked this code up from http://www.codeexamples.com/:  I have not had an opprotunity to try it.  Hope it helps.

If this does not work I have a DB template that will.  Email me and let me know.

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

@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);
@If(@IsNewDoc & @IsDocBeingSaved; @Subset(@DbColumn("" : "NoCache"; ""
: ""; "RMA Number"; 1); 1) + 1; RMAno)

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close