I am trying to remember where i found this but I use the following:
1: create a table with the name of AuditTrail with the following fields:
EditRecordID,EditDate,User,RecordID,SourceTable,So urceField,BeforValue,AfterValue (I set all to text/255)
2: Create a standard module with a name of basAuditTrail and insert the following (this is not my work and no copyright information was given)
[HTML]Const cDQ As String = """"
Sub AuditTrail(frm As Form, recordid As Control)
'Track changes to data.
'recordid identifies the pk field's corresponding
'control in frm, in order to id record.
Dim ctl As Control
Dim varBefore As Variant
Dim varAfter As Variant
Dim strControlName As String
Dim strSQL As String
On Error GoTo ErrHandler
'Get changed values.
For Each ctl In frm.Controls
With ctl
'Avoid labels and other controls with Value property.
'If .ControlType = acTextBox Then
Select Case ctl.ControlType
Case acTextBox, acCheckBox, acComboBox, acOptionGroup
If .value <> .OldValue Then
varBefore = .OldValue
varAfter = .value
strControlName = .name
'Build INSERT INTO statement.
strSQL = "INSERT INTO " _
& "AuditTrail (EditDate, User, RecordID, SourceTable, " _
& " SourceField, BeforeValue, AfterValue) " _
& "VALUES (Now()," _
& cDQ & Environ("username") & cDQ & ", " _
& cDQ & recordid.value & cDQ & ", " _
& cDQ & frm.RecordSource & cDQ & ", " _
& cDQ & .name & cDQ & ", " _
& cDQ & varBefore & cDQ & ", " _
& cDQ & varAfter & cDQ & ")"
'View evaluated statement in Immediate window.
Debug.Print strSQL
DoCmd.SetWarnings False
DoCmd.RunSQL strSQL
DoCmd.SetWarnings True
End If
'End If
End Select
End With
Next
Set ctl = Nothing
Exit Sub[/HTML]
3:on each form that you want to track changes insert the following to a [HTML]Form_BeforeUpdate() [/HTML] event
[HTML]Call AuditTrail(Me, Form name right here)[/HTML] so it would look something like this
[HTML]Private Sub Form_BeforeUpdate(Cancel As Integer)
Call AuditTrail(Me, Form name right here)
End Sub[/HTML]