Solved

Retreive Windows User ID when record is updated

Posted on 2016-09-16
6
23 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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 26

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

This very simple solution applies to a narrow cross-section of the "needs to close" variety. In this case, the full message in Event Viewer was in applog, Event ID 1000: Faulting application iexplore.exe, version 8.0.6001.18702, faulting module …
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…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…

706 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

19 Experts available now in Live!

Get 1:1 Help Now