Solved

Enhancement to Allen Browne Audit

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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

Suggested Solutions

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
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…
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.

733 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