Dear Ramzi,
Place this code in a Module: [Blue]
Private Declare Function apiGetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Public Function GetOSUserName() 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
GetOSUserName = Left$(strUserName, lngLen - 1)
Else
GetOSUserName = ""
End If
End Function
[Black]
Now Place text box on your form or wherever:
1): [Blue] Define a text box on your form( Call it ShowNetWorkName) [Black]
2): [Blue] Place this code in the Form Load Event:
Me.ShowNetworkName = GetOSUserName
[Black]
Hope This Helps,
Hap
Access Developer
-
Specializing in Access based Add-on Solutions for the Developer