insert windows username into a record automatically for audit trail

darren_access

Registered User.
Local time
Today, 09:21
Joined
Jan 8, 2018
Messages
57
I have a form used for data entry by several persons, and i would like to automatically insert the windows username into a user column for the record they are inserting. I have figured out how to get the username, but how do you pass it into the username column behind the scenes?

Thanks!
 
I use Me.[username] = Environ$("username")

My username (and hostname) are always part of the recordstructure
 
Some also argue in favour of ...
Code:
Me.Username = CreateObject("WScript.Network").Username
...because it is more secure. Windows Environment Variables as returned by the Environ() function can easily be spoofed, but this is a fine point.
hth
Mark
 
I use Me.[username] = Environ$("username")

My username (and hostname) are always part of the recordstructure

Just out of interest, what do you mean by hostname?
Its not one of the environ variables
 
Just out of interest, what do you mean by hostname?
Its not one of the environ variables

I started several years ago with "username" and "hostname", am not sure where the "hostname" description came from.
But indeed this name is not correct, because actually I get the Environ$("Computername") which I put in the hostname.

I just want to know where and when information is entered, and username and computername work good enough for my situation in combination with dateTime created and modified
 
Thanks for the tips. I've got it working. Unfortunately the network here is set up using non-personal names, so I'll have to do some swapping during the insert. I've created a table of users that contains their personal name and their pc login username. What would you recommend the best way to replace the names at insert or update time?
 
What I do...
I change them always, but keep a copy of the record in a logg table, similar structure
so table_A: ID, col1, col2, username, computername
table_A_Logg : IDLogg, ID, col1, col2, username, computername
I change the user and modified date in the record and insert in the afterupdate of the FORM the whole record into the logg table.

Maybe rough, but I have everything I need
 
Last edited:

Users who are viewing this thread

Back
Top Bottom