[AccessD] Windows Username

Jennifer Gross jengross at gte.net
Sun Mar 15 16:22:53 CDT 2009


Perfect Jim.  Worked like a charm.  Thank you.

Jennifer

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Jim Dettman
Sent: Sunday, March 15, 2009 2:04 PM
To: 'Access Developers discussion and problem solving'
Subject: Re: [AccessD] Windows Username


Jennifer,

  You can use the function below. Paste it into a general module with
the declares.  It will return either the computer name or user name. 

Jim.

Private Declare Function GetUserNameA Lib "advapi32.dll" (ByVal lpBuffer
As String, nSize As Long) As Long Private Declare Function
GetComputerNameA Lib "kernel32" (ByVal lpBuffer As String, nSize As
Long) As Long

Public Function WhoAmI(bReturnUserName As Boolean) As String

        ' Function returns either user name or computer name

        Dim strName As String * 255

10      If bReturnUserName = True Then
20        GetUserNameA strName, Len(strName)
30      Else
40        GetComputerNameA strName, Len(strName)
50      End If

60      WhoAmI = left$(strName, InStr(strName, vbNullChar) - 1)

End Function 

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Jennifer
Gross
Sent: Sunday, March 15, 2009 4:31 PM
To: 'Access Developers discussion and problem solving'
Subject: [AccessD] Windows Username

Happy Sunday,

How can I grab the Windows username from inside A2K?  The client uses
Terminal Server and is currently on Windows Server 2000, but will
shortly be upgrading to Windows Server 2003.

Thanks,

Jennifer

-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com

-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com
No virus found in this incoming message.
Checked by AVG - www.avg.com 
Version: 8.0.237 / Virus Database: 270.11.13/2001 - Release Date:
03/15/09 14:07:00





More information about the AccessD mailing list