Get Windows Login "User Name" from within Access.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Our group all log on to Windows XP Pro with their User Name and Password.
How do I retrieve the User's name from within Access 2003.
 
Dave,

I use the following:

Environ("Username")

If you need the domain as well then

Environ("UserDomain") & "\" & Environ("Username")

Hope this helps - probably easier than an API call, although I'm sure there
are reasons why an API call is more elegant/robust.

Jon.
 
Thanks Jon
Environ("Username") is great.
The API call corrupted my database big time.
I am not able to delete the new module or import the database to another file.
 
Jon Ley said:
Dave,

I use the following:

Environ("Username")

If you need the domain as well then

Environ("UserDomain") & "\" & Environ("Username")

Hope this helps - probably easier than an API call, although I'm sure
there are reasons why an API call is more elegant/robust.

It's not reliable if the user has any desire to spoof it. Anyone can
set an environment variable. But if you're not concerned with nefarious
users, it's okay.
 
Dave said:
Thanks Jon
Environ("Username") is great.
The API call corrupted my database big time.
I am not able to delete the new module or import the database to
another file.

I've never heard of that happening. How did it come about?
 
Good point, I'll bear it in mind. Probably beyond most of my users though!

Thanks,

Jon.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top