September 30, 2005 at 6:59 am
In Visual Basic for Applications in Access how can one obtain the name of the user who is logged on to Windows? I am not using Access security but I would like to pick up the user id of the person logged on to the PC.
Thanks
Steve
September 30, 2005 at 10:07 am
I think you have to use a windows API function to get the username. Here is the API declaration and a little function to return the windows username.
Declare Function GetUserNameA Lib "advapi32.dll" (ByVal lpBuffer As String, nSize As Long) As Long
Public Function GetUserName() As String
Dim UserName As String * 255
GetUserNameA UserName, 255
GetUserName = Left$(UserName, InStr(UserName, Chr$(0)) - 1)
End Function
Hope this helps.
October 3, 2005 at 3:48 pm
environ("USERNAME")
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply