G Guest Sep 6, 2005 #1 In a multi user enviroment i wish to use the XP user profile login name and store it in a table is this possible?
In a multi user enviroment i wish to use the XP user profile login name and store it in a table is this possible?
G Gijs Beukenoot Sep 6, 2005 #2 From Colin Richards : In a multi user enviroment i wish to use the XP user profile login name and store it in a table is this possible? Click to expand... This will return the username when called, so Me.fldLastUpdatedBy = GetUser() will fill the field with the currently logged on user. Option Compare Database Option Explicit Public Declare Function GetUserName Lib "Advapi32.dll" Alias "GetUserNameA" (ByVal ABuffer As String, nSize As Long) As Long Public Function GetUser() As String 'Returns Windows User LogOn ID On Error GoTo GetUser_Err Dim sUserName As String Dim lLength As Long sUserName = space(255) lLength = GetUserName(sUserName, Len(sUserName)) GetUser = Left(sUserName, lSize - 1) 'Removing the trailing chr(0) On Error GoTo 0 Exit Function GetUser_Err: GetUser = "Unknown" 'Although you might add some real errortrapping here On Error GoTo 0 Exit Function
From Colin Richards : In a multi user enviroment i wish to use the XP user profile login name and store it in a table is this possible? Click to expand... This will return the username when called, so Me.fldLastUpdatedBy = GetUser() will fill the field with the currently logged on user. Option Compare Database Option Explicit Public Declare Function GetUserName Lib "Advapi32.dll" Alias "GetUserNameA" (ByVal ABuffer As String, nSize As Long) As Long Public Function GetUser() As String 'Returns Windows User LogOn ID On Error GoTo GetUser_Err Dim sUserName As String Dim lLength As Long sUserName = space(255) lLength = GetUserName(sUserName, Len(sUserName)) GetUser = Left(sUserName, lSize - 1) 'Removing the trailing chr(0) On Error GoTo 0 Exit Function GetUser_Err: GetUser = "Unknown" 'Although you might add some real errortrapping here On Error GoTo 0 Exit Function
N Nikos Yannacopoulos Sep 6, 2005 #3 Colin, In the following page: http://www.mvps.org/access/api/api0008.htm you'll find some simple code for retrieving the user login. HTH, Nikos
Colin, In the following page: http://www.mvps.org/access/api/api0008.htm you'll find some simple code for retrieving the user login. HTH, Nikos