View Full Version : Recording user modification to form
nadrojcote 06-08-2009, 12:46 PM Hello, I am working on a database for my work, now I have followed a guide on how to log the time and date that the table was modified through the form, but now they want me to add the ability for it to log the user that made those changes on that date.
This is the guide i followed on how to create the macro to add the time and date modified fields.
http://office.microsoft.com/en-us/access/HA102412841033.aspx
Any help or tips as to what I am going to have to do to allow this to record the user that made the changes is greatly appreciated. Thanks!
pbaldy 06-08-2009, 01:00 PM One way is to get the logged in user with either the Environ() function or this:
http://www.mvps.org/access/api/api0008.htm
or CurrentUser() if you're using Access security.
gemma-the-husky 06-08-2009, 02:16 PM you can easily add an audit facility to capture key changes to data
ie who, which computer, when and what.
pbaldy 06-09-2009, 07:02 AM Are the date and time portions working correctly? Presuming so, let's see exactly how you're doing all 3.
nadrojcote 06-09-2009, 07:30 AM Ok, I have added the currentuser() to the macro the same way I did the time and date, as well I have added security and users. The time and date still work fine but it will not show a username in the User Modified field within the table or on the form where I set it to show. Is there anything I could be missing that is different than setting up the time and date macro?
pbaldy 06-09-2009, 07:38 AM Did you delete a post?
nadrojcote 06-09-2009, 07:57 AM Yes lol, I posted pretty much the exact same as my last post but after posting I realized I put usermodified() instead of currentuser() so I deleted it and recreated after I checked how i created the macro. Basically I thought that I messed up on my macro and that might be why it wasnt working so I deleted it, but when I checked the macro I did do it correct, so I am still stumped. I do not know a lot about access and macros but I did manage to follow the bouncing ball on the tutorial within my first post. Any help would be greatly appreciated as I am in a work practicum right now and getting this to work will most likely get me the job in the end. Thanks
pbaldy 06-09-2009, 08:00 AM Can you post the db, or at least the specifics of this macro? I can't think of why the user wouldn't work if you're doing it the same way as the others. I assume the textbox you're putting the value in is bound to the table?
nadrojcote 06-09-2009, 08:02 AM i do know a tad bit about vb.net if it will be easier to do this with code rather than a macro
nadrojcote 06-09-2009, 08:39 AM apparently you arent going to have the permissions to open that db so I will upload one that works right away
nadrojcote 06-09-2009, 08:46 AM Ok here is the db i have made some changes and the username and pass i pm'd you wont work you will need to use username-admin password-test
pbaldy 06-09-2009, 08:54 AM Your macro only has 2 lines in it. If I add a third SetValue with an "Item" of
[UserModified]
and "Expression" of
CurrentUser()
it works as expected. The VBA equivalent would be:
Me.UserModified = CurrentUser()
nadrojcote 06-09-2009, 08:55 AM I had that in there maybe the one i sent you wasnt updated? what macro was it that you were looking at?
pbaldy 06-09-2009, 08:56 AM The macro being called by the before update event of the Customers form, "LastModified".
nadrojcote 06-09-2009, 09:02 AM Thank you so much I have it working now, I was trying to create a new macro rather than editing the old one, You are a god among men my friend, if it wasnt for people like you, helping others in need then we would be no where!:D
pbaldy 06-09-2009, 09:17 AM LOL! No problem. The other macro looks correct, you just weren't calling it. Personally I'd use code, for a variety of reasons (more flexible, powerful, error handling...).
|