>Just curious what folks think out there regarding what's the best way to generate key field values when adding new records to tables.
>
>When my users click the ADD button, I've been running code to use the table in the key field order, go bottom, find the last value and add 1 to it for the new record's key field value.
>
>It seems to be working fine, though I realized I had to play with my SET DELETED ON/OFF commands so my next value was unique and not the same as a deleted record's.
>
>I know some folks keep separate tables to track the next available key value for their tables. I'm assuming it looks like a 2 field table, one for the table's name, one for the next value. You'd then check there for the next value you want to assign.
>
>Any way better than any other??
>
>MTIA!!
>
>Mandy
Only second way is better, because in multi-user environment you should assume that two or more users will add a record at the same time and get the same 'bottom' value. The separate table, besides two fields, also allow to apply temp lock on particular record, i.e. even if many users will request new keyvalue they will still get different numbers.
Edward Pikman
Independent Consultant