View Single Post
  #2  
Old June 5th, 2009, 08:17 PM posted to microsoft.public.access.tablesdbdesign
Armen Stein
external usenet poster
 
Posts: 507
Default New Database - Primary Key

On Fri, 5 Jun 2009 11:34:01 -0700, Trini Gal
wrote:

I've read a lot of the threads referencing Primary Key and I need a little
help. I'm creating a database for my company to track changes to channels.
This database will be accessed in different regions throughout the company
(possibly sometimes at the same time). I need to figure out how to create a
Primary Key for one of my tables. I've figure out how to use the DMax
function to increment #s, but if two users try to enter a new record at the
same exact time, one of them won't be able to save that record because the
one before got the #. I know this because its happened before.


Hi Trini,

Is there a reason that you aren't using an AutoNumber? Then Access
will manage it for you. However, you need to be okay with having gaps
in the sequence.

If you need your own method, then as you discovered the DMax method
does have this concurrency problem.

Alternatively, you can keep a "Next Available" number in another
configuration table, then write a small VBA function that opens the
recordset for update (locking it), incrementing the number, then
updating the record again. This ensures that only one user can
increment at a time.

Armen Stein
Microsoft Access MVP
www.JStreetTech.com