Highlight Records That Are In Use By Another User

B

Bateman28

Hi

I am trying to find some help to the following: I have created a multi-user
database that consists of 3 different business areas. Within each business
area there is a team of about 8 users that need to access about 1200 - 1500
records on a monthly basis.

What i want to do for each business area's work list, is create a function
that while one of the users is accessessing a specific record from within the
main record list, it will show the record that is being accessed in a
highlighted colour so that other
users that are in the main record list know not to access that record as it
is currently being worked on.

I have already put the Edit Record Lock on so that the warning message
appears. I have also set a condition on the form so that once the record has
been accessed it is then assigned to that user. Its just the initail issue
of users trying to access the same file that i'm trying to avoid, any help
would be greatly appreciated
 
S

Stefan Hoffmann

hi,

I have already put the Edit Record Lock on so that the warning message
appears. I have also set a condition on the form so that once the record has
been accessed it is then assigned to that user. Its just the initail issue
of users trying to access the same file that i'm trying to avoid, any help
would be greatly appreciated
This should work:

You need to operate your database using pessimistic locking and you need
an extra table to track the locks per table.

E.g. a lock table for the existing table 'MyTable':

MyTableLock: idMyTable, UserName


Public Function LockRecord(AId As Long) As Boolean

On Local Error GoTo LocalError

Dim db As DAO.Database
Dim sql As String

LockRecord = False

sql = "INSERT INTO MyTableLock (idMyTable, UserName) " & _
"SELECT TOP 1 " & AId & ", '" & GetUserName() & "' " & _
"FROM MSysObjects " & _
"WHERE NOT EXISTS (" & _
"SELECT 1 FROM MyTableLock WHERE idMyTable = " & AId & _
")"
Set db = CurrentDb
db.Execute sql, dbFailOnError
LockRecord = (db.AffectedRecords = 1)

LocalError:
Set db = Nothing

End Function

GetUserName() is a function retrieving the current user name. E.g. Win32
API GetUserNameA.

http://www.mvps.org/access/api/api0008.htm


mfG
--> stefan <--
 

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