Solved

Enhancement to Allen Browne Audit

Posted on 2010-08-25
6
485 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 58

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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
Familiarize people with the process of utilizing SQL Server views 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 Access…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

696 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