Question about optimistic locking: Error 3197 - how does it know?

G

Guest

With optimistic locking as I understand it if:
User1 opens a record and begins working / editing with it at 9:00 AM and
then gets called away from his desk before he can update the new mailing
address.

User2 could open the same record at 9:05 AM and make changes to FirstName at
9:10 AM and save .update her changes.

When User 1 returns to his desk at 9:25 AM he would go to .Update the record
and receive error 3197.

However, my question is how does the system track this for record level
optimistic locking?

How does it know that the data changes from 9:00 AM when User 1 started
working and when user 2 saved the changes underneath user 1 compared to 9:25
AM when User 1 tried to apply his changes.


Does it have some internal "last edited" date/time stamp?


Thank you for your time.
 
M

Marshall Barton

Maxer said:
With optimistic locking as I understand it if:
User1 opens a record and begins working / editing with it at 9:00 AM and
then gets called away from his desk before he can update the new mailing
address.

User2 could open the same record at 9:05 AM and make changes to FirstName at
9:10 AM and save .update her changes.

When User 1 returns to his desk at 9:25 AM he would go to .Update the record
and receive error 3197.

However, my question is how does the system track this for record level
optimistic locking?

How does it know that the data changes from 9:00 AM when User 1 started
working and when user 2 saved the changes underneath user 1 compared to 9:25
AM when User 1 tried to apply his changes.

Does it have some internal "last edited" date/time stamp?


SQL Server does use an internal time stamp, bu Access just
checks to see if the record you are updating is the same as
it was when it was retrieved (at the start of your editing).

Since the 9:00 record you want to update was changed at
9:05, the values you retrieved are not the same value in the
table at 9:25 and the conflict is recognized
 
G

Guest

So it just says:

If Me.txtFname(original value I started with before editing) =
rst.Clients!Fname Then
No changes were made, update
Else
Original value of Fname does not match the current value in the tables,
therefore changes must have been made. Error 3197


Is that basically it?

So then no matter if I have that record opened for 3 second or 3 years, the
system will still tell if changes were made and abort my update as the values
I started with do not match the values currently in the table just prior to
my update being applied?
 
M

Marshall Barton

That's my understanding if how it works. In a form, you
don't just get an error message, you are prompted to see if
you want your changes to override the other changes.
 
G

Guest

So then is there any way for me to use this feature with unbound forms?

Can I call this feature from the VBA itself?

Or do I have to use bound forms for it to do its magic?

Marshall Barton said:
That's my understanding if how it works. In a form, you
don't just get an error message, you are prompted to see if
you want your changes to override the other changes.
--
Marsh
MVP [MS Access]

So it just says:

If Me.txtFname(original value I started with before editing) =
rst.Clients!Fname Then
No changes were made, update
Else
Original value of Fname does not match the current value in the tables,
therefore changes must have been made. Error 3197


Is that basically it?

So then no matter if I have that record opened for 3 second or 3 years, the
system will still tell if changes were made and abort my update as the values
I started with do not match the values currently in the table just prior to
my update being applied?
 
M

Marshall Barton

If you are doing this in code, then the code is responsible
for dealing with the situation. I haven't had a need to use
an unbound data entry form in over12 years, but I think you
might need to do all this yourself. If you decide that you
always want to save the data. you could just Execute an
Update query. If you want to give users the same option
that access provides, then you might have to do the same
kinds of things Access that I've described or implement your
own timestamp field. or ???

From my point of view, there is almost never a real need to
use an unbound data entry form. This is a good thing
bevause it means that Access takes care of all this stuff
automatically for 99.99% of all situations. I will admit
that on rare occasions, I have used unbound text boxes for
users to enter data that is modified before placing it in
invisible bound controls.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top