Attribute VB_Name = "basNetworkUserName" Option Compare Database Option Explicit Private Declare Function tnl_UserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long Function NetworkUserName() ' Purpose: To get the user name logged on to the server ' Notes : Dim struser As String Dim ret As Long struser = String$(255, " ") ret = tnl_UserName(struser, 255) If ret <> 0 Then struser = Trim(struser) NetworkUserName = Left(struser, Len(struser) - 1) Else NetworkUserName = Null End If Debug.Print NetworkUserName End Function