.mdb  lock unlock problem.

Posted on 2011-02-12
Medium Priority
Last Modified: 2012-05-11
I have a multi user Delphi-Access application.
I am looking for a real simple code that i can make sure 2 people are not working on the same row at the same time.

I been reading about lock and unlock .
Is there a simple way just to make sure 2 people are not editing the same row at the same time.
Question by:Grant1842
LVL 32

Accepted Solution

Ephraim Wangoya earned 1200 total points
ID: 34880975

Thats really a function for the database to perform.
However if you want some kind of control, you can add a field to your tables that indicate that a record is currently in edit mode
You can make it a timestamp. If the record is opened, you insert the current time to that field. When the second user tries to open the same record, they receive a notification that the record is currently being edited and they can only view.

When the record is saved, set the timestamp field to null.
Using the timestamp, you can determine how long a record has been opened and if it is still valid, eg you don't expect someone to keep a record open for several hours
LVL 14

Expert Comment

ID: 34881355
congratulation, your on the Delphi Hall of fame, overall.
LVL 32

Expert Comment

by:Ephraim Wangoya
ID: 34881383

Thanks Systan
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

LVL 24

Assisted Solution

jimyX earned 400 total points
ID: 34881402
There are 3 types of records locking, you may read this article for more info:

The option you are after is:

In the MS Access go to:
Tools -> Options -> Advanced tab -> "Default record locking" check "Edited record".
LVL 19

Assisted Solution

Thommy earned 400 total points
ID: 34885972
If you are using ADOConnection, this might be an option for you...

Achieve Record locking in Delphi 5-6 with Access 2000
LVL 47

Expert Comment

ID: 34893706
What versions of Delphi and Access are you using?

How are your multiple users editing records? (configuration and UI)

It is possible to use pessimistic locking, but you pay a performance penalty.

Your code is supposed to receive (trap) an error when you try to change a row that has been changed by someone else.  Is this not happening?
LVL 12

Author Comment

ID: 34902347
Thanks for all your comments. I will try and sort through them.

I am using D2010 and access 2007.

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
The video will let you know the exact process to import OST/PST files to the cloud based Office 365 mailboxes. Using Kernel Import PST to Office 365 tool, one can quickly import numerous OST/PST files to Office 365. Besides this, the tool also comes…
When you have multiple client accounts to manage, it often feels like there aren’t enough hours in the day. With too many applications to juggle, you can’t focus on your clients, much less your growing to-do list. But that doesn’t have to be the cas…

586 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question