>lcSelect = Select() >Select MyTable >Go Bottom >lcLastKey = Alltrim(MyTable.MyKey) && e.g. [BFZZ] -> [BFZ'A] --> [BGAA] >NextKey = CalNextKey(lcLastKey) > > >* CalNextKey.prg or Function CalNextKey >Lparameter lcLastKey >For iX = Len(lcLastKey) to 2 Step -1 && will problem if [ZZZ] >If SubStr(lcLastKey, iX, 1) = [Z] && From Right to Left > * up the lcLastKey Till non-Z is found! > lcLastKey = left(lcLastKey, iX-2) + chr(asc(Substr(lcLastKey, iX-1,1))+1) + [A] + SubStr(lcLastKey, iX+1) >Else > * normal case > lcNewKey = left(lcLastKey, iX-1) + chr(asc(Substr(lcLastKey, iX,1))+1) + ; > Substr(lcLastKey, iX+1) > Exit && leave loop >Endif >EndFor > >If Left(lcNewKey, 1) > [Z] && Independent of Hardware Platform > messagebox('OverFlow Error!!',16,'Calculate Next ID') > Return .F. >else > Return lcNewKey >ENDIF > >NOTE this is sth like calculation Sum with Logic Gate! >>