Question Record Locking - front or back end?

davesmith202

Employee of Access World
Local time
Today, 15:19
Joined
Jul 20, 2001
Messages
522
I have Access 2007 in a multi-user environment and we need to lock the edited records. The database is split into a front end and back end.

Do we apply the record locking settings to the front end or back end?

Thanks,

Dave
 
You can set the Record Locks Property on the Form as well as on the Access Options - -> Advanced Section. on FE.
 
It would be, as apr pillai says, set for each form (better to do it that way than to do it Wholesale). Set the form's Record Locks to EDITED Record. That way, if the record is NOT being edited it won't be locked and inaccessable to other users.
 
HI Bob,

Could you explain why it is better to set the Record Locks = Edited Record at the form level instead of "wholesale"?

TIA -
~RLG
 
Access uses optimistic locking, which will lock just at the time it needs to update. But it is best, if you find you need to lock some, to ONLY do it where it is absolutely necessary or else you may find yourself with a lot of locking errors as people just click into a record on a form. Use record locking very sparingly. I don't use it at all unless there is a very good reason to do so. I had one form for an organization which they had multiple people needing to update the same records and so we selected the EDITED RECORD for that particular form and that helped them. But the rest of the forms didn't have that issue so it wasn't necessary, nor did we want the behavior, for the rest of the forms.
 
Thank you for the quick reply. That makes sense. I think in this situation, there is very little chance that multiple users will be needing to update the same record - they each have their own clients and should only be updating the ones they are responsible for.

Cheers,
~RLG
 
an important question is - why do you think you NEED a pessimistic record locking strategy?
 
they each have their own clients and should only be updating the ones they are responsible for.

So instead of locking the records, why not just set it up so that they can only see the ones they are responsible for?
 
Hi Bob,

For the most part it is set up that way. Each person is assigned a particular program and the records are filtered by program. But there is one instance where there are 3 people assigned to the same program. They need to be able to see each others records. So I think it will be ok.

Hi Dave,
I'm new to Access and reading and learning and asking questions to find the best practice (since books don't necessarily tell you that, they just tell you how things work). I don't want my database to get corrupted after all the hard work I have put into it. It sounds like I don't need to worry about it (at least as far as locking records is concerned)!

Cheers,
~RLG
 
renag

the thing about updates and record locking is that it is all designed to guard against inconsistent updates. you can have as many users reading/viewing records as you like all at the same time - but only 1 person writing a record at a time.

if you have two writers, then this can happen

writer A reads a value from a record, and changes it to a different value
writer B reads the same value from the same record, and changes it to another different value

if both writers do this there is no guarantee about the sequence in which they read, and then write the cnage - so the end result may be wrong.To prevent this one strategy is to lock the record before the read/edit/write to insure the integrity of the porcess. but locking records will prevent the (harmless) readers being able to access the record as well - so a record locking strategy has to be considered carefully, and records have to be locked for the minimum amount of time. if not lots of things can get "stuck" - such as searches or reports which have to wait for the locked record to be released.

so even with locking you dont generally want to open a form, and lock a table or record - the user might leave the unedited record on the screen, or even just go to lunch! result can be a "stuck" and unresponsive system.


there is also a possiblilty of deadlock arising with a record locking system:

writer A locks record 1, and tries to lock record 2 - in the meantime
writer B locks record 2, and tries to lock record 1

result deadlock - neither process can proceed - so your program has to manage this by getting one of the processes to release the locks it has already acquired, normally after trying unsuccessfully to acquire the second lock for a fixed number of times


one final point is (I think) that record locking is actually achieved by locking the page(s) on which the record lives - which in turn will lock other records that happen to share those pages

---------------
the alternative strategy to this, as bob alluded, is called optimistic locking - this in fact is no locking, but immediately before a write takes place, the record is re-read to confirm that it didn't change since you read it initially, and therefore the write is safe to proceeed.


the caveat to all this - is to consider the situation if you need to make multiple updates, all of which have to succeed - and the solution here is to wrap them all in a transaction, which can be undone completely, if the whole process fails.


all this transaction management becomes so complex it is much better to rely on the facilites provided by the database manager (i mean Jet, Ace, SQL whatever) than to try and write apps to provide all these facilities.


Hope this helps

----------
 
Last edited:
Good morning Dave,

Thank you for that great explanation! I looked up locking in one of my books and it says that Access 97 (V8) and earlier, locked a 2 KB page each time somebody updated, inserted or deleted rows. In Access 2000 this was increased to 4 KB but Access 2000 (V9) and later also support record-level locking so multi-users can update records stored on the same data page. Their recommendation was to leave the "Open databases by using record-level locking" check box selected unless your application needs to update hundreds of rows such as with a query.

TTFN,
~RLG
 

Users who are viewing this thread

Back
Top Bottom