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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

finding Current access user name in VBA 2

Status
Not open for further replies.

Zycmi

IS-IT--Management
Jun 19, 2002
42
CA
I am currently working with an access database, and am finally setting up user accounts. I would like to know if there is a code string which would allow me to retrieve the Current User's username, and dump it into a string. It would make my life that much easier... thanks.


Zycmi
 
Do you mean a username particular to that db or their network username? If you mean for that db, you can create a login form and put the login username into a global variable declared in a module.
<module>.<variable> = <username>
You can also just make the login form invisible and refer to it for the username.

I've also seen &quot;user = ...&quot; in autoexec.bat. That sets an environment variable which is retrieved with
VBA.Environ$(&quot;user&quot;)

Hope these help. I know there are ways of getting someone's network login name or computer name, but I don't know the code.
 
The variable &quot;CurrentUser&quot; identifies the current user.

To test it out type, Debug.Print CurrentUser
 
If you have Access User and Group security set up ( So a user has to &quot;log on&quot; to the Access database ) then you can use the built in function CurrentUser() which returns a string as in :-

MsgBox &quot;Current User is &quot; & CurrentUser()


You can, therefore, use CurrentUser() as if it was a Variable of type String and any point in you code.



'ope-that-'elps.

G LS
 
I have the API call code to get the network userid, if that is what's needed...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top