Not sure if you mean Access Logon User ID or Network ID. For Access it's:
CurrentUser()
Otherwise it's:
Delclare this API in any module:
Private Declare Function GetUserName Lib "advapi32.dll" _
Alias "GetUserNameA" (ByVal lpBuffer As String, nSize _
As Long) As Long
Then use this function:
Public Function GetUser() As String
Dim l As Long, sUser As String
On Error Resume Next
sUser = Space$(255) 'Init string
l = GetUserName(sUser, 255) 'call API
'strip null terminator
If l <> 0 Then
sUser = Left(sUser, InStr(sUser, Chr(0)) - 1) 'null terminated string
If Len(sUser) > 50 Then
sUser = Left$(sUser, 50)
End If
GetUser = sUser
Else
GetUser = "<Not Found>" 'raise an error msg here if you like
End If
End Function
Works well,
--Jim