PC logon User Name from XP inside of Access 2003 ?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

In a multi user enviroment i wish to use the XP user profile login name and
store it in a table is this possible?
 
From Colin Richards :
In a multi user enviroment i wish to use the XP user profile login name and
store it in a table is this possible?

This will return the username when called, so
Me.fldLastUpdatedBy = GetUser()
will fill the field with the currently logged on user.

Option Compare Database
Option Explicit

Public Declare Function GetUserName Lib "Advapi32.dll" Alias
"GetUserNameA" (ByVal ABuffer As String, nSize As Long) As Long

Public Function GetUser() As String
'Returns Windows User LogOn ID
On Error GoTo GetUser_Err

Dim sUserName As String
Dim lLength As Long

sUserName = space(255)

lLength = GetUserName(sUserName, Len(sUserName))
GetUser = Left(sUserName, lSize - 1) 'Removing the trailing chr(0)

On Error GoTo 0
Exit Function
GetUser_Err:

GetUser = "Unknown" 'Although you might add some real errortrapping
here
On Error GoTo 0
Exit Function
 
Back
Top