Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to get Windows Login/Username in Table? 2

Status
Not open for further replies.

lout

MIS
Dec 19, 2001
2
US
How do I get the windows login/username in a table?
Everytime somebody adds a record to the table I would like to have one of the fields filled with this username.

When user logs on to the network she/he has to supply his username. I want to be able to put this login/username into a table.
I have written a VBA function (Username) to get this login/username.
It is also possible to get this login/username in a textbox on a form.
But I cannot get this data into a table.
Is there a way to use the function (Username) from within a table?
Or
Is there a way to retrieve the value from a textbox on a form and place it in a table?
Or
Is there any other (simple) solution?

 
Add a field to your table and set the default value to the value of your function. Mike Rohde
rohdem@marshallengines.com
 
Mike,

I have tried to enter my written function in the Default value of a field (in a table). But this does not work.

The function I have written is called "UserName" and stored in a Module name "UserInfo"
When I write in the Default Value =UserName() and try to save the table Access (2000) replies with 'Unknown function' and Access does not save the table.
If I use the Expression builder from the Default Value cell and click on functions I only see 'Built-in functions'. My own written functions are not there.

If I try the same but only from a FORM then I can see (and use) my own functions.

 
Ok, try this. Add a field to the table and put a text box on the form that is bound to that field. Use the 'before insert' event of the form to call your function and assign a value to the textbox.

Private Sub Form_BeforeInsert(Cancel As Integer)
Me.WhoInserted = username()
End Sub

Of course, replace 'WhoInserted' with the name of your text box. Mike Rohde
rohdem@marshallengines.com
 
You can also use the Environ() function to return this kind of stuff.

Environ("UserName") returns logged in user.
Environ("UserDomain") returns domain logged into.
Environ("ComputerName") returns the computer name.
 
Checkout novell user login name...that worked for me just perfect..

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top