Mark said:
I want to use the username to auto populate the employee field when
clearing a ticket. Can it be pulled from the information that they
logged in with (not windows password).
Perhaps you are looking for logged in username of the computer or
network vs. database username. You might want to use something like this
in a module:
'----------------------------------------------------------------------------------
'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
'------- -------- ------
-----------------------------------------------------
' 002 05/25/99 ash Trim Numeric chars from end of UserName
' 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
sBuffer = Space$(255)
lSize = Len(sBuffer)
'sbuffer includes an Ascii.Null. lSize is one larger than the real
length.
Call GetUserName(sBuffer, lSize)
If lSize > 0 Then
lSize = lSize - 1
If IsNumeric(Mid$(sBuffer, lSize, lSize)) Then
lSize = lSize - 1
End If
ReturnUserName = Left$(sBuffer, lSize)
Else
ReturnUserName = vbNullString
End If
End Function