General discussion

Locked

MS Access 97: Getting NT Username on For

By parier ·
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.

This conversation is currently closed to new comments.

5 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

MS Access 97: Getting NT Username on For

by M.R.Chambers In reply to MS Access 97: Getting NT ...

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

Collapse -

MS Access 97: Getting NT Username on For

by parier In reply to MS Access 97: Getting NT ...

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.

Collapse -

MS Access 97: Getting NT Username on For

by donq In reply to MS Access 97: Getting NT ...

=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

Collapse -

MS Access 97: Getting NT Username on For

by parier In reply to MS Access 97: Getting NT ...

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.

Collapse -

MS Access 97: Getting NT Username on For

by parier In reply to MS Access 97: Getting NT ...

This question was closed by the author

Back to Software Forum
5 total posts (Page 1 of 1)  

Related Discussions

Related Forums