Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to get the login name?

Status
Not open for further replies.

macluv22

Programmer
Feb 28, 2002
7
0
0
NL
Is it possible to get the login name (Windows login) in Access (or VBScript)?
 
Sure it's strLogon = Environ(S_USER) or strLogon = Environ("Username") Maq B-)
<insert witty signature here>
 
Sorry, I forgot to put quotes around &quot;S_USER&quot; Maq B-)
<insert witty signature here>
 
Here is some code that I used to write the userid to an error log. I used this because the users wanted only one user id but I had to figure out who was having the problems. X-)

Const lpnLength As Integer = 255
Dim status As Integer
Dim lpName, lpUserName As String

lpUserName = Space$(lpnLength + 1)
status = WNetGetUser(lpName, lpUserName, lpnLength)

If status = NoError Then
' This line removes the null character. Strings in C are null-
' terminated. Strings in Visual Basic are not null-terminated.
' The null character must be removed from the C strings to be used
' cleanly in Visual Basic.
lpUserName = Left$(lpUserName, InStr(lpUserName, Chr(0)) - 1)
Else
lpUserName = &quot;&quot;
End If

lpUserName id the userid

HTH,

Jude
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top