IF EMPTY(TheMainKeyField) > USE (DBF()) AGAIN IN 0 ALIAS AutoNumber ORDER TheMainKeyIndex > GOTO BOTTOM IN AutoNumber > REPLACE TheMainKeyField WITH AutoNumber.TheMainKeyField+1 > USE IN AutoNumber >ENDIFBear in mind that this won't work in a multi-user situation, where two users might grab that record at the same time. The separate table for keys works better here.