Discussion Locked

Access: Grabbing a users username

0 helpful
4 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

We use Windows NT and Access 97 for many users to created passwords on a wide
variety of systems and users. Access automatically prints them all to one
printer and were trying to find a way to see who is printing what. I would like
to know if there is a way to have the users NT username display on the Access 97
report and when they print it out so we will know who is not following procedure(s).

4 replies

by tclere

You can use Windows API function to get the current login name:

Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long

Dim lpBuff As String * 25
Dim ret As Long, sUserName As String

'Get the User Name
ret = GetUserName(lpBuff, 25)
sUserName = Left(lpBuff, InStr(lpBuff, Chr(0)) - 1)
sUserName = UCase(sUserName)

Hope this helps!

by parier

I need to know where to add this and how. The place I want this is on a form. The form has no table or queries. Just used for entering names, passwords and stuff like that. Now where and how do I enter this code? WHen it works, I will award youthe points and thank you!
Eric
sergeant@connix.com

This discussion is closed to new replies.