capture username and freeze it

slsy1212

Registered User.
Local time
Today, 22:25
Joined
Sep 1, 2004
Messages
13
hi, i have a form where i need to capture the name of the person logged in to record that they are responsible for making that entry. i used one of the threads in this forum to make a login form and then use dlookup to capture the name of the user that is currently logged in, which works, but the problem is that this value changes for all entries and forms every time someone different logs in.

how do i freeze the field so that after it captures the name of the person logged in who made that entry, it doesn't change anymore?

This is the code i have so far, as the control source for a text box:
=DLookUp("User","qryCurrentUser")

Hope someone can help, thanks!
 
If you have A2002, It think, then you can set the default value of the vield to:

=Environ("username")
 
Hi, i actually have Access 2000... and wouldn't even that keep changing as the username of the person logged on changes? :confused: Thanks...
 
A control with =DLookUp("User","qryCurrentUser") as its ControlSource is NOT bound! Nothing is being saved to the table. Somehow I don't think that that is what you want.

If you only want to save the value when the record is added, place the following code in the BeforeInsert event of the form:

Me.UpdateBy =DLookUp("User","qryCurrentUser")

If you want to log the name every time the record is updated, put the single line of code in the form's BeforeUpdate event.
 
Hi, thanks for all your help... you're totally right Pat, i've now realized that the field has to be bound to the table in order to record the user for each entry that is made. I understand what you mean by inserting the code you provided in the BeforeInsert event of the form, but how do i write it to that field in the table/form? I guess there has to be something in that new field i have now created that reads the name from qryCurrentUser and then saves it without reading it anymore. Any help is extremely appreciated, thanks!
 
I gave you an example of the single line of code that you need. Just change the field and query names to your own.
 

Users who are viewing this thread

Back
Top Bottom