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
Solved

Enhancement to Allen Browne Audit

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

809 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