Display user in a record in multi-user database

calvinle

Registered User.
Local time
Today, 02:19
Joined
Sep 26, 2014
Messages
332
Hi,

Can anyone guide me, if it's possible, how to display the current user Environ(Username) that is editing the record?

I have set my access options to lock the record if a user is in the edit mode, but if I create a field [rec_user], is it possible to display in that field the user that is currently in that edit mode?

The purpose of this is for other user to be able to know who is currently working on that record.

Thanks
 
fwiw, I would not lock records.

this is generally unnecessary in any "normal" database.

it doesn't solve your question, but I have never required pessimistic record locking in any database. I can only imagine it being required for serious high-end financial apps - and even then it won't be the only solution.
 
you'll have a lockout situation when you set record lock on. imagine a scenario where one user is editing record 1, goes to lunch and comes back 2 hours later. the record is lock and nobody is able to edit the record.
let access handle the locks by setting record lock to no lock, it only get locked when the user saved the record and not while editing it.
 
I have set an idle timer to kick the user out the database if he is idle. I will need to find a way so tat 2 user do not edit the record at the same time. Also, I do let Access handle the record lock. I just set the lock-edit in the options Advanced, so Access is still controlling it right?
 
you did a manual override.
 
So without locking the record is it possible to know who is accessing the record?
 
without being awkward, I doubt if you can identify who is using a record, and I can't think it matters particularly in a multi-user system - other, as I say, in maybe very specialised systems.

"using" a record is an ephemeral thing anyway - it changes all the while. without locking records, any and all users could view the same record simultaneously. It only ever becomes an issue if two users try to change the record at the same time - which is why the default optimistic locking is generally an acceptable strategy.
 
Ohh I just have a tought. Maybe a workaround way for it.
When the user open view the record form, it will update the field with their username. So there is a check before the record is open. If the field is empty, then the user that open the record has name in the field.
If the other user open the record form, and the checking verify that the field already contain data, then it will open the form as read only.
If Me.field = null then docmd.open frmname: Else: docmd.open frmname,,acreadonly

Could be a solution rght?
 
Could be. Test it and let us know what you find.
 
Code:
Option Compare Database
Option Explicit

Public lngUserID As Long
Public strNetUserName As String
Public strUserName As String
Public bytUserSecLevel As Byte
Public bolUserStatus As Boolean
Public bolAddRecs As Boolean
Public bolEdtRecs As Boolean
Public bolDelRecs As Boolean
Public lngPeopleId As Long


'This is used by GetUserName() to find the current user's
' name from the API
Declare Function Get_User_Name Lib "advapi32.dll" Alias _
                 "GetUserNameA" (ByVal lpBuffer As String, _
                 nSize As Long) As Long

Function ResetView()
DoCmd.Echo True
DoCmd.Hourglass False
End Function

Function GetUserName() As String
    Dim lpBuff As String * 25
 
    Get_User_Name lpBuff, 25
    GetUserName = Left(lpBuff, InStr(lpBuff, Chr(0)) - 1)
End Function

Hi I use such a code for my username and i have it that it auto welcomes the user upon startup of the database and then holds that they are the user.

I only allow them to view certain stuff if i have allowed that username specifically using other coding to view it or add/edit what ever it maybe.

Wonder if it can help you maybe.

Have you tried googling it as i think there will be alot of stuff out there on this regarding SQL and stack servers.....

Hope you find the solution.
(DO NOTE I THINK THIS CODE ONLY WORKS ON WINDOWS PC'S
Code:
advapi32.dll
!!!)
 

Users who are viewing this thread

Back
Top Bottom