Hi, am trying to fill a text box with the current windows username in Access 2000, but im having trouble.
So far im using this..
And on my form, I have a text box with 'control source' set to =CurrentUser.Code:Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Private Function CurrentUser() As String
Dim strBuff As String * 255
Dim x As Long
CurrentUser = ""
x = GetUserName(strBuff, Len(strBuff) - 1)
If x > 0 Then
x = InStr(strBuff, vbNullChar)
If x > 0 Then
CurrentUser = UCase(Left$(strBuff, x - 1))
End If
End If
End Function
Problem is this returns 'Admin', which I assume is what im logged into the DB as. But i want the windows username, not this.
Anyone help please?
lee
