Solved

Database record changes - How to audit?

Posted on 2015-01-28
5
110 Views
Last Modified: 2015-02-02
I have a table named tblAudit.  In this table in addition to an auto-number ID field are 7 fields.  They are:

EditDate, User, RecordID, SourceTable, SourceField, BeforeValue, and AfterValue.

Any time a change is made be it edit, addition, or deletion is made I need the audit table to have a record made to it capturing the values.  How can I do this?  Do I need some code for every form?  Or a module that works for every change?

What would to code look like?  I've never done this before.

--Steve
0
Comment
Question by:SteveL13
  • 2
  • 2
5 Comments
 
LVL 57
ID: 40575184
You would add in some code and hook it up in every form.  See:

http://allenbrowne.com/appaudit.html

Bounce back if you have any questions (I'm sure you will).

Jim.
0
 

Author Comment

by:SteveL13
ID: 40575822
Wow!  Lots to absorb.  Back to you after I review and see what I can do with it all.  Thanks so far.
0
 
LVL 84

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 500 total points
ID: 40577043
If you're using 2010 or later you can use the new Data macros. Scott Gem shows how to do this here: https://scottgem.wordpress.com/2012/10/18/audit-trail-using-data-macros-2/
0
 

Author Comment

by:SteveL13
ID: 40577544
Scott,

I like your suggestion.  Just a couple of comments:

When adding a new record I get a record in the tblAuditTrail.  But I wish it would capture the value I entered in each field for FieldName and NewValue.  It isn't doing that.

When deleting a record I wish it would capture the record ID that was deleted.  It isn't doing that.

Can the code be altered to do these things?
0
 
LVL 84
ID: 40584980
Can the code be altered to do these things?
You haven't posted any code or screenshots, so the only way I can answer that is "Maybe" ...
But I wish it would capture the value I entered in each field for FieldName and NewValue.  It isn't doing that.
It's up to you to capture those values if you want. You'd need to use the "SetValue" action for each field that you want to capture.
When deleting a record I wish it would capture the record ID that was deleted.  It isn't doing that.
Data Macros offer a BeforeDelete and AFterDelete action, so you could probably write to the audit log in the BeforeDelete event.
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

760 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

22 Experts available now in Live!

Get 1:1 Help Now