open database < DatabaseNameHere > create table ids (TableName c(30), CurId i) index on upper(TableName) tag TableNameAnd add this to stored procedures (possibly replace current NewID if it's there).
*DBC Stored proc FUNCTION NewID LPARAMETERS tcTableName LOCAL lcTableName, lnOldArea, lcOldReprocess lnOldArea = SELECT() lnOldReprocess = SET('REPROCESS') * Uppercase Alias name lcTableName = upper(iif(parameters() = 0, alias(), tcTableName)) * Lock reprocess - try once SET REPROCESS TO 1 IF !USED("IDS") USE ids IN 0 ENDIF * If no entry yet create and return 1 IF !SEEK(lcTableName, "Ids", "tablename") INSERT into ids (TableName, CurId) values (lcTableName,1) SELECT (lnOldArea) SET REPROCESS TO lnOldReprocess RETURN ids.CurId ENDIF * Lock, increment id, unlock, return CurId value DO while !RLOCK('ids') * Delay before next lock trial lnStart = seconds() DO while seconds()-lnStart < 0.01 ENDDO ENDDO * Increment REPLACE ids.CurId WITH ids.CurId + 1 in 'ids' UNLOCK in 'ids' SELECT (lnOldArea) SET REPROCESS TO lnOldReprocess RETURN ids.CurId ENDFUNCFor any table you create add a PKId field (you might name it as TableName_Id but be sure to check it's indexed and for ease of use name index tag PKId). For Id field's default enter expression :