I apologize. This is the function I downloaded:
Public Function MyAuditData()
' Comments : This function is used to provide an audit trail of all
changes to a record
Dim frmActive As Form
Dim ctldata As Control
Dim mySQL As String
Dim mySQL2 As String
Dim mySQL3 As String
On Err GoTo NextCtl
Set frmActive = Screen.ActiveForm
'For new records
mySQL = "INSERT INTO tblAuditTrail (UserName, Timestamp, Value, Field,
Action) VALUES ( """ & CurrentUser & """, Now(), ctldata.value,
ctldata.name, 'New Record Added')"
'For edits
mySQL2 = "INSERT INTO tblAuditTrail (UserName, Timestamp, Value,
OldValue, Field, Action) VALUES ( """ & CurrentUser & """, Now(),
ctldata.value, ctldata.oldvalue, ctldata.name, 'Edited Record')"
'For deleted data
mySQL3 = "INSERT INTO tblAuditTrail (UserName, Timestamp, Value,
OldValue Field, Action) VALUES ( """ & CurrentUser & """, Now(),
ctldata.value, ctldata.oldvalue, ctldata.name, 'Data Deleted')"
' If new record, record it in audit trail and exit sub.
If frmActive.NewRecord = True Then
DoCmd.RunSQL mySQL
End If
'Check each data entry control for change and record
For Each ctldata In frmActive.Controls
' Only check data entry type controls.
Select Case ctldata.ControlType
Case actextbox, acComboBox, acCheckBox, acOptionButton
'Skip unbound controls (3 is ControlSource)
If ctldata.Properties(3) = "" Then GoTo NextCtl
Select Case IsNull(ctldata.Value)
'Check for deleted data
Case True
If Not IsNull(ctldata.OldValue) Then
DoCmd.RunSQL mySQL3
End If
'Check for new or changed data
Case False
If IsNull(ctldata.OldValue) And Not IsNull(ctldata.Value) Then
DoCmd.RunSQL mySQL2
'If control had previous value, record previous value.
ElseIf ctldata.Value <> ctldata.OldValue Then
DoCmd.RunSQL mySQL2
End If
End Select
End Select
NextCtl:
Next ctldata
End Function
Thanks!
-Sandspirit