Unique number for multiple fields in one form

I am using the following formula to create a unique doc number in an asset database I have created for all IT eqiupment. My problem is that I now need to create unique asset numbers looking up from different views for diff kind of assets for ex cpu’s need an asset number starting with a C and Keyboards starting with a K but my formula I am using does not seem to work when I add any kind of prefix to the number. Is there any other way I can do this.

Field formula for field called DNumber:

Temp := @TextToNumber( @Subset( @Text(@DbColumn( “”:“NoCache”; “”:“”; “NLV”; 1)); 1));

@If( @IsError( Temp); 1; Temp + 1)

View Formula for view NLV

SELECT ((Form = “assett”)) & dnumber != “”

Subject: RE: Unique number for multiple fields in one form

First of all, you can’t put a letter in a number field and have it save successfully. DNumber will have to be a Text field.

If you want unique numbers as in this set (C01, C02, K01, K02), then make your formula …

Temp := @DbLookup(“”:“NoCache”; “”:“”; “NLV”; [letter-indicating-asset-type]; 1);

Temp1 := @If(@IsError(Temp); 1; @TextToNumber(@RightBack(Temp; 1)) + 1);

[letter-indicating-asset-type] + @Text(Temp1)

If you want unique numbers as in this set (C01, C02, K03, K04, C05), then change the first column value in your lookup view to @RightBack(DNumber; 1) and make your formula …

Temp := @Subset(@DbColumn(“”:“NoCache”; “”:“”; “NLV”; 1); 1);

Temp1 := @If(@IsError(Temp); 1; @TextToNumber(Temp) + 1);

[letter-indicating-asset-type] + @Text(Temp1)

There may be issues with it re-computing on refreshes, or duplicate numbers because two people were composing a doc at the same time, but I can’t cover all the gotchas.

Cheers,

Bill