Associating the logged in user to records they inputted?

  • Thread starter Thread starter Alex Anderson
  • Start date Start date
A

Alex Anderson

Hello everyone,

Is it possible to associate the user that logs into access to records
they inputted? I want to keep an audit log so I can see who inputted what.
Is this possible?


Thank you
Alex Anderson
 
It's doable, but only if you're using Forms for input.

Add an UpdatedBy field to your table, and in the form's BeforeUpdate event,
set the value of the field.

If you've applied security to the database and want their Access login name,
use CurrentName to get it. If you want their Windows Network name, check the
code in http://www.mvps.org/access/api/api0008.htm at "The Access Web"
 
Douglas,

I'm having a bit of trouble applying what you've told me to do. I would
like to use the CurrentUser function, however I don't know how to apply the
syntax. If you could, can you give me a step by step procedure how to
associate records created by the CurrentUser logged in.

Thanks for holding my hand.
Alex Anderson
 
You can only use CurrentUser if you've applied security to your database,
and that's not a task to be taken lightly.

For details on how to apply security, read
http://support.microsoft.com/support/access/content/secfaq.asp thoroughly
several times. Work on a copy of your database in case something goes wrong.
Make sure you do not skip any steps.

For my money, http://www.mvps.org/access/api/api0008.htm is far simpler.
Copy what's between Code Start and Code End into a new module, save it (make
sure you don't name the module the same as the function), then use
fOSUserName() where you want the ID.
 
Douglas,

I'm trying to follow your suggestion, and the whole time I was using
"CurrentName" instead of "CurrentUser." Now, I copied over the code, saved
the module to my database and made sure it was named as a different name.
As for the my form, here's where I'm a little lost. I set up a text box and
on the event "Before Update" I put what you told me to put, "fOSUserName()."
I think I'm going the right way about this, however its not grabbing the
logged in user. Am I putting the "fOSUserName()" in the wrong place? I
tried putting on the main form "BeforeUpdate" field but I think it doesn't
know where to store the value, that is why I made the text box and assigned
"fOSUserName()" to the "BeforeUpdate" and associated (under data) to the
field I made within table design. Thanks for your help.

Alex Anderson
 
Doug,

Don't laugh... But on my form, under my text box properties I have the
following code under the Event/Before Update, "= fOSUserName () " without
the "". I know I'm doing something wrong.

Thank you
Alex Anderson
 
Doug,

Yeah, that link has some cool examples. The auditTrail2 one works
great. It would have taken me years to figure out what Roger did.

Thanks
Alex Anderson
 
Doug,
Is it possible for me to get instructions on how to do this. I've read
the thread and viewed the website, but I don't know how to use the VBA
interface, and am unclear as to what the UpdateBy field and BeforeUpdate
event are (though I understand an event is a procedure or function, right).

I would like to call the windows login name and have it added to a field
in a record by default.
 
Back
Top