Solved

Enhancement to Allen Browne Audit

Posted on 2010-08-25
6
482 Views
Last Modified: 2013-11-28
The website http://allenbrowne.com/tips.html is a well known one for access guidance.

There is a standard bit of code here that provides audits for table changes.

I seek an enhancement to this code - does this exist??

The standard audit in the site give the value of ALL fields prior to a record change.
It also gives the value of ALL fields after a record change.

I would like a bit of code that analysed the records in the audit table and then identified which SPECIFIC fields changed.

i.e. the audit table simple shows ALL fields in the record.  I just want to report on those that changed.

If you are not familiar with this audit then it may be difficult to comment.
The bottom line is that I am wondering if someone has already written the code I want.  I.e. I do not want to re-invent the wheel (actually I am not really capable of doing s
o!)

Any views?
0
Comment
Question by:Patrick O'Dea
6 Comments
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 33523232
Have you given this a shot yourself first?
What was the result?

Are you good with VBA? SQL?

You will have to clearly state exactly how this system should function, how the changes are logged and saved, ...ect

This can be simple or complex, depending on what you want and how much hand-holding you need.

JeffCoachman
0
 

Author Comment

by:Patrick O'Dea
ID: 33523577
Thanks boag2000

My VBA/SQL would not be good enough.

"You will have to clearly state exactly how this system should function, how the changes are logged and saved, ...ect"

I am hoping that the code might already exist.  Therefore I cannot be precise about requirements.  Roughly I require output like "John changed the 'Date of Birth' from 01/02/2010 to 03/03/2010".







0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 250 total points
ID: 33523750

see this link

How to create an audit trail of record changes in a form in Access
http://support.microsoft.com/?kbid=197592
0
 
LVL 57

Assisted Solution

by:Jim Dettman (Microsoft MVP/ EE MVE)
Jim Dettman (Microsoft MVP/ EE MVE) earned 250 total points
ID: 33523758
I just looked at the code which is this:
' Copy the latest edit from temp table as "EditFrom".
sSQL = "INSERT INTO " & sAudTable & " SELECT TOP 1 " & sAudTmpTable & ".* FROM " & sAudTmpTable & _
" WHERE (" & sAudTmpTable & ".audType = 'EditFrom') ORDER BY " & sAudTmpTable & ".audDate DESC;"
db.Execute sSQL
' Copy the new values as "EditTo"
sSQL = "INSERT INTO " & sAudTable & " ( audType, audDate, audUser ) " & _
"SELECT 'EditTo' AS Expr1, Now() AS Expr2, NetworkUserName() AS Expr3, " & sTable & ".* " & _
"FROM " & sTable & " WHERE (" & sTable & "." & sKeyField & " = " & lngKeyValue & ");"
db.Execute sSQL
' Empty the temp table.
sSQL = "DELETE FROM " & sAudTmpTable & ";"
db.Execute sSQL, dbFailOnError

He's used an * to imply all fields by default. What surprised me is that he's really not doing what I would call auditing per say at this point, but merely making a copy of the records. You'd have to do further processing to determine what change was made.
This was undoubtly done for performance reasons as the way I've seen it done in the past was to loop through a forms controls, and then compare .oldvalue to the current value. If there was a difference, you'd log the change.
I suppose you could modify this code so that you could pass a field list to the SQL string, but really that's only part of it. I think rather you'd need to pass a reference to the form and carry out the operation I outlined above, then let the routine write the change records for each field. Certainly not impossible by any stretch, but I'm sorry to say I simply don't have the time right now. I am WAY too far behind on too many things.
JimD.

0
 

Author Closing Comment

by:Patrick O'Dea
ID: 33550219
Thanks for help.

Incidentally capricorn1 I have used the one on the microsoft site before.  It is fairly good but not seem to check all data types.
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
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…

773 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