SET ORDER TO TAG mykey GOTO BOTTOM lnNextValue = INT(VAL(SUBSTR(mykey,4))) + 1 ... ... INSERT INTO mytable (mykey,...) VALUES ('HMD'+PADL(lnNextValue,5,'0'),...) SET ORDER TO ...You also have to be aware that using just numeric digits as above limits you in the number of records. If the mykey field is a Char(8) as above, then the numeric part is 5 digits or a limit of 99,999 records. Not a good design. You can either use a integer field type and a 'prefix' field of C(3), or if you want a single character field, then use an increment of 0-Z (that is 0,1,2,3,4,5,6,7,8,9,A,B,C,...X,Y,Z -- base 36 instead of base 10) which gives 36**5 records allowed (60,466,176)