0

I am using this code in my MS Access VBA: How to get logged-in user's name in Access vba?

It works perfectly fine. However, our foreign employees need to use the software on a server, and it is unable to retrieve the username. We are signed in as usual. The server version is Windows Server 2008 SP2.

Any suggestions?

Best regards, Emil.

Community
  • 1
  • 1
Emil Olsen
  • 332
  • 1
  • 9
  • 25

1 Answers1

3

I don't know which method you are using (there are several answers), but this one suggested by HansUp is easy and hopefully works on the Server too:

https://stackoverflow.com/a/32565953/3820271

Public Function GetUserName() As String
    ' GetUserName = Environ("USERNAME")
    ' Better method, see comment by HansUp
    GetUserName = CreateObject("WScript.Network").UserName
End Function
Community
  • 1
  • 1
Andre
  • 26,751
  • 7
  • 36
  • 80