Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Autonumber field 1

Status
Not open for further replies.

Fadius

IS-IT--Management
Jul 25, 2001
139
0
0
US
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.
 

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.
 
Yes it has to 5 characters in length. I have tried the @Unique function but is has more than 5 characters.
 
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.
 
hi
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

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

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.

BH2
 
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....
 
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.

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

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,

BH2
 
I picked this code up from 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.
cmchess

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);
ANOTHER METHOD:
@If(@IsNewDoc & @IsDocBeingSaved; @Subset(@DbColumn("" : "NoCache"; ""
: ""; "RMA Number"; 1); 1) + 1; RMAno)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top