Inserting the username into a table

Kaybaj

Registered User.
Local time
Today, 17:14
Joined
Apr 15, 2010
Messages
67
my database displays the username on the forms, but i want the username of the person who is entering a data to be inserted in the table where the data is being entered, so that when you look at a record, you can know the user that entered it. for audit purpose.
thanks any help will do
 
use the same function you use to display as the default value of the field in the table.
 
this is what i used
=[Forms]![PASSWORDS].[txtemployeename]
the form "passwords" is hidden not closed so the me.txtusername text box on my forms refer to it.
but now using this as the default value in a table is not working. can you give me another idea
thanks
 
You can also, in the form's BEFORE UPDATE event set the values if the fields are included in the form's recordset.
 
i have this code on the sUBFORM with a UserStamp and TimeStamp field.

Private Sub Form_BeforeInsert(Cancel As Integer)
Me.UserStamp = CurrentUser()
Me.TimeStamp = Now()
End Sub
Private Sub Form_BeforeUpdate(Cancel As Integer)
Me.UserStamp = CurrentUser()
Me.TimeStamp = Now()
End Sub
 
Just to note that unless you are using Microsoft Access Security, CurrentUser() would return admin for everyone. So you would want to either use

=VBA.Environ("username")

or this API which is a little more secure than Environ.
 
yeah, I have a user level security.... another thing is that we are using the citrix environment
 
i don't use ULS because i use access 2007, what i did was to create a table for usernames and passwords and i use dlookup to lookup the password against the username and it's working.
 
in order for me to be able to display the username on my forms, i created a textbox on my login in form with =[Combo22].[column](1) as the control source. when a user logs in the password is correct the swithboard opens and the login form goes into hiding so that all the forms will continue to reference it.
 
the usernames and passwords are not system's so i need to make sure the usernames goes into a table against every record entered, so that for every record entered you can get the person who entered the record. that is my challenge.

thanks all
 

Users who are viewing this thread

Back
Top Bottom