Site Search:
Sign in | Join | Help
4Penny.net

Microsoft Access

Tricks and Tips for Microsoft Access

Get the current User

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

 Function user()

    Dim s As String
    Dim cnt As Long
    Dim dl As Long
    Dim CurUser As String
    cnt = 199
    s = String(200, 0)
    dl = GetUserName(s, cnt)
    If dl <> 0 Then
        CurUser = Left$(s, cnt - 1)
    Else
        CurUser = ""
    End If
    user = CurUser
End Function

 

Comments

 

Roy Lawrence said:

Brilliant.

Why can't Microsoft tell you things like this!

July 2, 2008 7:40 AM

Leave a Comment

(required)  
(optional)
(required)  
Add

About Steve Gray

Steve is a seasoned (translate: old) developer in VB and ASP.NET. He spends most of his time in Dynamics GP, writing custom mods for consulting firms. Crystal reports, eConnect, VS Tools for Dynamics... anything that comes along.