By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,501 Members | 1,216 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,501 IT Pros & Developers. It's quick & easy.

Identify Computer UserName in Access VBA

P: 68
Hi, I am struggling with creating a unique name for a series of table that are temporary tables enabling my report to load quickly and accurately. What I want to do is attach the Windows UserName to the end of the table name and have the reports run from that table.

My database is using Access 2010 running on Windows 7 and is accessed by users from the network. In most cases I don't run into file sharing issues but in this case where I need temporary tables to run the reports from I run into issues where someone has the report open and another user goes to open the report and gets a message that the table is locked. I asked my IT department to allow me to push the front-end to desktops and got a no in response. So my solution is to make the tables unique to the user.

If I could pick up something that was unique to the user that would allow me to create and delete tables based on that user and other users would not be affected. When I look at the properties of the Locking File created when Access is open and go to details it lists the first person in the database as the Owner. That makes me think there has to be a way to pull the UserName, Owner, ComputerID or some other Identifier that can make my table name unique.

Have you run into this? Can you help? Thank you for taking the time to read my post.
Mar 13 '14 #1

✓ answered by zmbd

If you split your database, then each user will have their own copy of the front end; thus, the local copy will have their version of the temporay table without conflicting with others.

The following can be spoofed.
Environ("Username") gets the username of the person logged into Windows
Use the API call: Search here on Bytes for Access User name. VBA: Sample Code to Retrieve the Current User Name

Also be carefull of using Access's logged in user name in ACC2010 or ACCDB files, it will always return admin for the name.

Share this Question
Share on Google+
3 Replies


Seth Schrock
Expert 2.5K+
P: 2,951
Environ("Username") gets the username of the person logged into Windows. However, instead of using this as part of a temp table name, I would recommend adding a field to your temp table for the username and then have your report filter the table based on that field.
Mar 13 '14 #2

zmbd
Expert Mod 5K+
P: 5,397
If you split your database, then each user will have their own copy of the front end; thus, the local copy will have their version of the temporay table without conflicting with others.

The following can be spoofed.
Environ("Username") gets the username of the person logged into Windows
Use the API call: Search here on Bytes for Access User name. VBA: Sample Code to Retrieve the Current User Name

Also be carefull of using Access's logged in user name in ACC2010 or ACCDB files, it will always return admin for the name.
Mar 13 '14 #3

P: 68
ZMBD that worked! Thank you.
Mar 13 '14 #4

Post your reply

Sign in to post your reply or Sign up for a free account.