Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting user names

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I tried this as a new module and then in the Immediate area I typed fOSUserName but did not get any user names logged on the network. Please advise how I can retrieve the UserName with which the user is logged into the
network?


[tt]

Private Declare Function apiGetUserName Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long

Function fOSUserName() As String
' Returns the network login name
Dim lngLen As Long, lngX As Long
Dim strUserName As String
strUserName = String$(254, 0)
lngLen = 255
lngX = apiGetUserName(strUserName, lngLen)
If lngX <> 0 Then
fOSUserName = Left$(strUserName, lngLen - 1)
Else
fOSUserName = &quot;&quot;
End If
End Function
[/tt]
 
If you're using Access Security, try CurrentUser. If you've got NT clients, try =Environ(&quot;UserName&quot;)

HTH

Craig
 
you have to type:
? fOSUserName
that should do it for you, I tried it on win2000, and it worked, I am not sure about win98
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top