Discussion Locked

MS Access 97: Getting NT Username on For

0 helpful
5 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. MS Access 97 automatically prints them all to one printer and were trying to find a way to see which users are 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). For example, If my username is jsmith in NT, then can I have a field/text box show that jsmith printed a report/form from MS Access 97 as a footer or on the bottom of the form.

5 replies

by m.r.chambers

Try having a look at this code. It finds the
user's name and displays it in a simple form,
but you may be able to adapt it for your
purposes. BTW, this works for win 95 but I
don't know about NT. (I didn't write this, it
was sent to me by someone a fair while ago)
----
Option Compare Database
Option Explicit
Public dbs As Database
Private Declare Function apiGetUserName Lib
"advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String,
nSize As Long) As Long

Function fOSUserName() As String
' Returns the network login name
Dim lngLen As Long, lngX As Long
Dim strUserName As String
strUserName = String$(254, 0)
lngLen = 255
lngX = apiGetUserName(strUserName, lngLen)
If lngX <> 0 Then
fOSUserName = Left$(strUserName,
lngLen - 1)
Else
fOSUserName = ""
End If
End Function

Function startup()

Dim strWhoAmI As String

'Get username from above function
strWhoAmI = fOSUserName

'Display username
MsgBox "The Current User Name is:" & vbCrLf &
strWhoAmI, vbInformation

End Function

----
M.R.Chambers

by parier

Users are on a NT network, usernames are partial of real names (ie John smith would be smitjo. Need those names to appear in the field. There about 20 users that use this DB and we need to know how to add their user names so we can keep track of who did what. Can I have more details, I am not too familiar with access.

by donq

=CurrentUser()

Set a text field to Current User in the After Update Event

Private Sub coaPK_AfterUpdate()

' SET THE AUTOMATED UPDATE VALUE TO THE CURRENT CLOCK TIME
' EVERY TIME THIS FIELD VALUE IS CHANGED.
coaUpd = Now()
' AUTOMATICALLY SET THE LOGGED-ON USER NAME TO Luid.
coaLuid = CurrentUser()

End Sub

by parier

Users are on a NT network, usernames are partial of real names (ie John smith would be smitjo. Need those names to appear in the field. There about 20 users that use this DB and we need to know how to add their user names so we can keep track of who did what. Can I have more details, I am not too familiar with access.

This discussion is closed to new replies.