Get Windows Login "User Name" from within Access.

D

Dave

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.
 
J

Jon Ley

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.
 
D

Dave

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.
 
D

Dirk Goldgar

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.
 
D

Dirk Goldgar

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?
 
J

Jon Ley

Good point, I'll bear it in mind. Probably beyond most of my users though!

Thanks,

Jon.
 
Top