Capturing Network User IDs in a Table/Database

  • Thread starter Thread starter Traci
  • Start date Start date
T

Traci

Currently I have a "personnel" table that captures the
individuals name, title, etc. When I want only
one "survey" response per individual, I request that they
select their name from the table that is a look-up.

What I would LOVE to do, is capture their user ID which
they have to log onto the PC/network to access the survey.
If I can capture their user ID, then if they fill out a
survey, I can allow them to preview/change their survey
only, OR allow them to add a survey if they have not
already done so.

Thank you for any input.

Traci Frazer
 
Try this function:

'---------------------------------------------------------------------------
-------
' Code
'---------------------------------------------------------------------------
-------
'GetUserName
'
'Purpose:
' This service defines the Library routine to fetch the Network UserName.
'
'Parameters:
'
'Rev Num Date Author Description of Change
'------- -------- ------ ----------------------------------------------
-------
' 001 03/01/99 ash Code Courtesy of Dev Ashish
'---------------------------------------------------------------------------
-------
Declare Function GetUserName Lib "advapi32.dll" _
Alias "GetUserNameA" (ByVal lpbuffer As String, nSize As Long) As Long


'---------------------------------------------------------------------------
-------
'ReturnUserName
'
'Purpose:
' This service returns the Network UserName.
'
'Parameters:
' None.
'
'Rev Num Date Author Description of Change
'------- -------- ------ ----------------------------------------------
-------
' 001 03/01/99 ash Code Courtesy of Michael Kaplan
'---------------------------------------------------------------------------
-------
Public Function ReturnUserName() As String
On Error Resume Next

Dim sBuffer As String
Dim lSize As Long
Dim Status As Long

sBuffer = String$(254, 0)
lSize = Len(sBuffer)

Status = GetUserName(sBuffer, lSize)
If Status <> 0 Then
ReturnUserName = left$(sBuffer, lSize - 1)
Else
ReturnUserName = vbNullString
End If

End Function


hth,
Andy
 
Back
Top