Solved

Enhancement to Allen Browne Audit

Posted on 2010-08-25
6
480 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 119

Accepted Solution

by:
Rey Obrero 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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

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…
In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …

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

19 Experts available now in Live!

Get 1:1 Help Now