472,129 Members | 1,680 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,129 software developers and data experts.

Multi user and auto increment

Is it true that if I split my access database in backend and frontend and I
implement custom auto increment for the ID fields, that my database is ready
to be used in a multi-user environment? I found a zillion messages about
auto increment and read some of them but it's confusing. Can someone point
me to a simple custom auto increment example that I can download?
Thank you,
john
Sep 15 '06 #1
2 5248
john wrote:
Is it true that if I split my access database in backend and frontend
and I implement custom auto increment for the ID fields, that my
database is ready to be used in a multi-user environment? I found a
zillion messages about auto increment and read some of them but it's
confusing. Can someone point me to a simple custom auto increment
example that I can download? Thank you,
john
The built in AutoNumber is the most robust "auto-applied" value in a
multi-user environment. Custom-coded auto-increment solutions can work well
in multi-user environments, but only if you do it right. The two methods
that work reliably are...

********************
Store the "NextID" auto-increment value in a table. When a new record is
saved you use code to...
Grab the value from the NextID table while applying an exclusive lock on
it
Apply the value to your record and save it
Increment the value in the NextID table and save, then release the table
lock.

********************
Use DMax() + 1 in the BeforeUpdate event of the form doing insertions.
BeforeUpdate is the ONLY event that ends with the record being committed to
disk so it has the smallest window of time where two users might possibly
calculate the same NextID value. The only caveat with BeforeUpdate is that
it can fire multiple times over the life of a record so your code needs to
add a test for either NewRecord or a Null ID.

BeforeInsert has the most appropriate sounding name for doing this, but
there is an indefinite period of time between that event firing and the
record being saved. During that interval all other users will grab that
same value and you will have conflicts.

The DefaultValue property has the same issue. The value would be calculated
as soon as the New Record position of the form is painted on the screen, but
any length of time could pass before a record is actually entered and saved.
Additionally, setting the Default Value property with a DMax() + 1
expression doesn't work at all in a continuous form (even with only one
user).

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com

Sep 15 '06 #2
Thanks for the info, which will save me a lot of time.
john

"Rick Brandt" <ri*********@hotmail.comschreef in bericht
news:mM*****************@newssvr12.news.prodigy.co m...
john wrote:
>Is it true that if I split my access database in backend and frontend
and I implement custom auto increment for the ID fields, that my
database is ready to be used in a multi-user environment? I found a
zillion messages about auto increment and read some of them but it's
confusing. Can someone point me to a simple custom auto increment
example that I can download? Thank you,
john

The built in AutoNumber is the most robust "auto-applied" value in a
multi-user environment. Custom-coded auto-increment solutions can work
well in multi-user environments, but only if you do it right. The two
methods that work reliably are...

********************
Store the "NextID" auto-increment value in a table. When a new record is
saved you use code to...
Grab the value from the NextID table while applying an exclusive lock
on it
Apply the value to your record and save it
Increment the value in the NextID table and save, then release the
table lock.

********************
Use DMax() + 1 in the BeforeUpdate event of the form doing insertions.
BeforeUpdate is the ONLY event that ends with the record being committed
to disk so it has the smallest window of time where two users might
possibly calculate the same NextID value. The only caveat with
BeforeUpdate is that it can fire multiple times over the life of a record
so your code needs to add a test for either NewRecord or a Null ID.

BeforeInsert has the most appropriate sounding name for doing this, but
there is an indefinite period of time between that event firing and the
record being saved. During that interval all other users will grab that
same value and you will have conflicts.

The DefaultValue property has the same issue. The value would be
calculated as soon as the New Record position of the form is painted on
the screen, but any length of time could pass before a record is actually
entered and saved. Additionally, setting the Default Value property with a
DMax() + 1 expression doesn't work at all in a continuous form (even with
only one user).

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com

Sep 15 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Tom | last post: by
9 posts views Thread by abprules | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.