Audit Trail Query

Purpleswanage

Registered User.
Local time
Today, 06:59
Joined
Jan 31, 2008
Messages
15
re. ghudson's audit trail code... Absolutely brilliant, thanks.

DOH! It would help if I included the code I was using!

Function AuditTrail()
On Error GoTo Err_Handler

Dim MyForm As Form, C As Control, xName As String
Set MyForm = Screen.ActiveForm

'Set date and current user if form has been updated.
MyForm!Updates = MyForm!Updates & Chr(13) & Chr(10) & _
"Changes made on " & Date & " by " & CurrentUser() & ";"

'If new record, record it in audit trail and exit sub.
If MyForm.NewRecord = True Then
MyForm!Updates = MyForm!Updates & Chr(13) & Chr(10) & _
"New Record """
End If

'Check each data entry control for change and record
'old value of Control.
For Each C In MyForm.Controls

'Only check data entry type controls.
Select Case C.ControlType
Case acTextBox, acComboBox, acListBox, acOptionGroup
' Skip Updates field.
If C.Name <> "Updates" Then

' If control was previously Null, record "previous
' value was blank."
If IsNull(C.OldValue) Or C.OldValue = "" Then
MyForm!Updates = MyForm!Updates & Chr(13) & _
Chr(10) & C.Name & "--previous value was blank"

' If control had previous value, record previous value.
ElseIf IIF(IsNull(C.Value),"",C.Value) <> C.OldValue Then
MyForm!Updates = MyForm!Updates & Chr(13) & Chr(10) & _
C.Name & "==previous value was " & C.OldValue
End If
End If
End Select
Next C

TryNextC:
Exit Function

Err_Handler:
If Err.Number <> 64535 Then
MsgBox "Error #: " & Err.Number & vbCrLf & "Description: " & Err.Description
End If
Resume TryNextC
End Function

The fields that I am tracking changes in a linked to tables containing 2 columns, the unique ID and the description. At present the report generated displays the ID of the previous value i.e. 'Originator==previous value was 1'. What I am wondering is if it is possible to amend the code to the return the description instead i.e. 'Originator==previous value was Joe Bloggs'. If this is possible how would I go about amending the code to achieve this?

Please bear in mind I am a complete novice so 'idiot proof' assistance required :-)

Thanks in advance

Helen
 
Last edited:

Users who are viewing this thread

Back
Top Bottom