General discussion

Locked

WINNT Username to a Field from ACCESS 97

By parier ·
approx 20 users from NT accounts create a password form for the end user. we want to know who is printing these password sheets. Our standard for usernames are John Smith would be smitjo. Is there a way to get that username to appear on a access FORM. FYI, this is a stand alone form, but everyone has a WINNT username. 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 Stand alone FORM 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 form from MS Access 97 as a footer or on the bottom of the form.

Thank you!

This conversation is currently closed to new comments.

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

All Comments

Collapse -

WINNT Username to a Field from ACCESS 97

by donq In reply to WINNT Username to a Field ...

To capture AND RETAIN the last user ID that signed on AND made a change:
1) create a text field named "Luid" (for Last User ID) within the recordset in question. (the one being printed)
2) add the field to the query (if any) and Form used to request the report.
3) set the Luid fields default property (on the Form ONLY) to "=CurrentUser()" leaving the quotes off.
4) If you don't want the logged on user to be able to focus on, or change his/her ID manually set the Luid fields Enabled property to "No".
5) If you don't want the current user to even know big brother is watching set the Luid fields Visible property to "No".
6) Enter "Luid = CurrentUser()" omitting the quites to the After Update event that runs the report BEFORE the reportis called within the code snippet.

If you just want the User ID to print whenever the report prints enter an unattached field in the report and set its default value to =CurrentUser()

Collapse -

WINNT Username to a Field from ACCESS 97

by parier In reply to WINNT Username to a Field ...

Please read the whole request. PLease not that just -currentuser() will only return the current user in Access, which by default is Admin. I actually need the persons user name whom is logged into Win NT. If your name was Eric Parisek, your user name would be parier. PARIER is what I want to return on each form. Get it? If not, let me know at eparisek@mtga.com

Collapse -

WINNT Username to a Field from ACCESS 97

by abone In reply to WINNT Username to a Field ...

Not sure whether you still need this as your message says answered, but ;

EXAMPLE
-------

1. Type the following code into a new module:

' Makes sure all variables are dimensioned in each subroutine.
Option Explicit ' Access the GetUserNameA function in advapi32.dll and
' call the function GetUserName.
Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" _
(ByVal lpBuffer As String, nSize As Long) As Long

' Main routine to Dimension variables, retrieve user name
' and display answer.
Sub Get_User_Name()

' Dimension variables
Dim lpBuff As String * 25
Dim ret As Long, UserName As String

' Get the user name minus any trailing spaces found in the name.
ret = GetUserName(lpBuff, 25)
UserName = Left(lpBuff, InStr(lpBuff, Chr(0)) - 1)

' Display the User Name
MsgBox UserName
End Sub

2. Run the macro Get_User_Name. Note that the current user name will appear in a
message box.

For more info see MS Knowledgbase article Q152970

Regards

Andy Bone

Collapse -

WINNT Username to a Field from ACCESS 97

by parier In reply to WINNT Username to a Field ...

What is the difference form the 3rd resoultion (which is what I needed) to this one? Please reply to eparisek@mtga.com

Also, answered only means others have supplied answers to my request - thats all.

Collapse -

WINNT Username to a Field from ACCESS 97

by WorkerBee In reply to WINNT Username to a Field ...

Use Environ("UserName") to get the NT username of who is currently logon on to the workstation. It works for NT 4.0 Workstation if thats what you're using.

Collapse -

WINNT Username to a Field from ACCESS 97

by parier In reply to WINNT Username to a Field ...

Finally! I have posted this wuestion 3 times and I have received some pretty long suggestions and to think this is exactly what I wanted -I'm speechless!

This is what I needed and is currently working. . .

="Created by" & Environ("UserName")& " on " & now()
which is
Created by Parier on 4/14/01 12:33:15 PM


Thanks a million!

Collapse -

WINNT Username to a Field from ACCESS 97

by parier In reply to WINNT Username to a Field ...

This question was closed by the author

Back to Web Development Forum
7 total posts (Page 1 of 1)  

Related Discussions

Related Forums