>PARAMETER lcKeyName > >LOCAL lnKeyNum > >IF NOT USED("keylist") > USE keylist IN 0 >ENDIF >IF SEEK(ALLTRIM(lcKeyName),"keylist","idxKname") > REPLACE keynum WITH keynum+1 IN "keylist" > lnKeyNum = keylist.keynum >ELSE > lnKeyNum = 0 >ENDIF >USE IN keylist >RETURN lnKeyNum >There's a bit of error-checking you can add to this routine.
PARAMETER lcKeyName LOCAL lnKeyNum IF NOT USED("keylist") USE keylist IN 0 ENDIF lnKeyNum = 0 IF SEEK(ALLTRIM(lcKeyName),"keylist","idxKname") IF RLOCK() && You don't want two users getting the && same number.... REPLACE keynum WITH keynum+1 IN "keylist" lnKeyNum = keylist.keynum UNLOCK ENDif ENDIF *USE IN keylist && You will only do this until the && first time you do a large APPEND FROM && into this table. :-) RETURN lnKeyNumNow that I think about it, it might be better to set lnKeyNum to .NULL., rather than 0: it's a better out-of-bounds indicator.