Solved

Retreive Windows User ID when record is updated

Posted on 2016-09-16
6
31 Views
Last Modified: 2016-10-30
I have a database and want to store the username that made the update in Access 2010.  How do I do this?  I was looking online and all the solutions appear to be overengineered.  Can someone help with this?
0
Comment
Question by:mtrussell
6 Comments
 
LVL 47

Accepted Solution

by:
Dale Fye (Access MVP) earned 250 total points
ID: 41801735
I use the code found here: http://www.access.mvps.org/access/api/api0008.htm

and then set the default value of the field in the database to:

=fosusername()
0
 
LVL 34

Assisted Solution

by:PatHartman
PatHartman earned 250 total points
ID: 41801819
I use the Environ("username") for the apps where I don't require a login.  You can also get the computer name that way if you want it - Environ("computername")


In the BeforeUpdate event of every form that updates a table that includes the ChangeBy column -

Me.ChangeBy = Environ("username")

I don't know if this produces different results from what Dale posted but the fousername() as written only works for 32-bit office installations.  You would need to fix it to use it in a 64-bit environment.
0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 41802132
No, Pat, you don't need to fix it for a 64-bit environment, you need to fix it for 64 bit Office, it works fine in 32 bit versions of Office.

Difference is you cannot spoof fosusername, but you can (if you know what you are doing) change the Environ("UserName") value.
0
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
LVL 34

Expert Comment

by:PatHartman
ID: 41802151
That's what I said in the preceding sentence.  Reading the two sentences together the statement should be clear.

So they return the same thing except that you can modify the value stored by Environ() if you are technically savvy.
0
 

Author Comment

by:mtrussell
ID: 41806445
Thanks guys.  It worked.
0
 
LVL 27

Expert Comment

by:MacroShadow
ID: 41865717
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.

I have recommended this question be closed as follows:

Split:
-- Dale Fye (Access MVP) (https:#a41801735)
-- PatHartman (https:#a41801819)


If you feel this question should be closed differently, post an objection and the moderators will review all objections and close it as they feel fit. If no one objects, this question will be closed automatically the way described above.

MacroShadow
Experts-Exchange Cleanup Volunteer
0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We were having a lot of "Heartbeat Alerts" in our SCOM environment, now "Heartbeat" in a SCOM environment for those of you who might not be familiar with SCOM is a packet of data sent from the agent to the management server on a regular basis, basic…
Many companies are making the switch from Microsoft to Google Apps (https://www.google.com/work/apps/business/). Use this article to learn more about what Google Apps has to offer and to help if you’re planning on migrating to Google Apps. It is …
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

930 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now