Solved

Retreive Windows User ID when record is updated

Posted on 2016-09-16
6
50 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 48

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 37

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 48

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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 37

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…

726 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