Hi I want to know an easy way to get data out of a record I have just inserted.

For example at the moment I have a database used for storing orders. When an order is made I run a query which gets a "free" orderID by selecting the highest orderID in the table and adding one. All subsequent queries, functions etc can then use this ID.

However this will take a long time if the table has a large number of records. Also bad things will happen if someone inserts another record in between this process happening and the actual insert. Although I guess I could change the lock type.

Is there a way I can insert a record and have the orderID an autonumber field and then get the orderID of the record inserted.

Hope this makes sense,

Thanks

Alex