B
bbcdancer
Having worked out how to use the Environ("username") method to obtain a
users login ID as a point of tracing records enter in MS Access. I
encountered problems using the Environ("username") method in Access
2000 and 2003.
A friend has cut and paste the below code as a solution, but I'm not
too sure how to display the username login details in a text or label
box in a form, so the user can see their login profile.
Could you provide me some simple sets to using to doing this.
Kind regards and many thanks,
Brenda
Option Compare Database
Option Explicit
Private Declare Function GetComputerNameA Lib "kernel32" (ByVal
lpBuffer As String, nSize As Long) As Long
Private Declare Function GetUserName Lib "ADVAPI32.dll" Alias
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Public Function GetComputerName() As String
On Error GoTo Err_GetComputerName
Dim Username As String * 255
Call GetComputerNameA(Username, 255)
GetComputerName = Left$(Username, InStr(Username, Chr$(0)) - 1)
Exit_GetComputerName:
Exit Function
Err_GetComputerName:
MsgBox Err.Description
Resume Exit_GetComputerName
End Function
Public Function GetCurrentUserName() As String
On Error GoTo Err_GetCurrentUserName
Dim lpBuff As String * 25
Dim ret As Long, Username As String
ret = GetUserName(lpBuff, 25)
Username = Left(lpBuff, InStr(lpBuff, Chr(0)) - 1)
GetCurrentUserName = Username & ""
Exit_GetCurrentUserName:
Exit Function
Err_GetCurrentUserName:
MsgBox Err.Description
Resume Exit_GetCurrentUserName
End Function
users login ID as a point of tracing records enter in MS Access. I
encountered problems using the Environ("username") method in Access
2000 and 2003.
A friend has cut and paste the below code as a solution, but I'm not
too sure how to display the username login details in a text or label
box in a form, so the user can see their login profile.
Could you provide me some simple sets to using to doing this.
Kind regards and many thanks,
Brenda
Option Compare Database
Option Explicit
Private Declare Function GetComputerNameA Lib "kernel32" (ByVal
lpBuffer As String, nSize As Long) As Long
Private Declare Function GetUserName Lib "ADVAPI32.dll" Alias
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Public Function GetComputerName() As String
On Error GoTo Err_GetComputerName
Dim Username As String * 255
Call GetComputerNameA(Username, 255)
GetComputerName = Left$(Username, InStr(Username, Chr$(0)) - 1)
Exit_GetComputerName:
Exit Function
Err_GetComputerName:
MsgBox Err.Description
Resume Exit_GetComputerName
End Function
Public Function GetCurrentUserName() As String
On Error GoTo Err_GetCurrentUserName
Dim lpBuff As String * 25
Dim ret As Long, Username As String
ret = GetUserName(lpBuff, 25)
Username = Left(lpBuff, InStr(lpBuff, Chr(0)) - 1)
GetCurrentUserName = Username & ""
Exit_GetCurrentUserName:
Exit Function
Err_GetCurrentUserName:
MsgBox Err.Description
Resume Exit_GetCurrentUserName
End Function