UPDATE KeyTable SET @ReturnKey = LastKey = LastKey + 1 WHERE ... select @ReturnKey -- return to caller>Thanks, good point. Yes, I can make the order number field in the order header table an autoincrement. I was trying to duplicate what we currently do with VFP without an autoincrement, but you make a good point.