>I'm looking for different ways people assign unique keys in multi user environments. My boss would like to use the record number, which sounds like a bad idea to me given that we would never be able to pack the table among other issues. Do we need to get more sophisticated than setting the order to the right index and doing:
>GO BOTT
>nNewID=myTable.key+1
>INSERT INTO myTable (key) VALUES(nNewID)
>
>Would it make sense to have a property hold the next value and put code in the access method to encapsulate the process? Thanks for any feedback on this basic task.
>
>Marcus.
RECNO() is very dangerous. Not only can you not pack, but if your table becomes corrupted, it could cause serious problems. Also, when buffering, you get a negative RECNO() until you commit.
Doing GO BOTTOM method also does not work in a multi-user situation.
Look at the KB article on Primary Keys on my web site. It defines Primary Keys and gives you code that you can put in your application. I've had several people use it and none reports problems.
Craig Berntson
MCSD, Microsoft .Net MVP, Grape City Community Influencer