Audit Trail in Access 97 Question

Liz_I3

Well-known Member
Joined
Dec 30, 2002
Messages
647
Office Version
  1. 2016
Platform
  1. Windows
I got the following code from Richard Rensel to create an Audit Trail in Access 97. My problem is that my form contains a subform and changes made on the subform are not being recorded. How can I change the code to include the subform?
Thanks Liz

Private Sub Form_BeforeUpdate(Cancel As Integer)
On Err GoTo TryNextC
Dim MyForm As Form
Dim ctl As Control
Dim strUser As String
Set MyForm = Screen.ActiveForm
strUser = fOSUserName


' Set date and current user if form has been updated.
MyForm!Updates = MyForm!Updates & Chr(13) & Chr(10) & "Changes made on " & Now & " 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 """
Exit Sub
End If

' Check each data entry control for change and record old value of Control.

For Each ctl In MyForm.Controls

' Only check data entry type controls.
Select Case ctl.ControlType
Case acTextBox, acComboBox, acListBox, acOptionGroup, acCheckBox
If ctl.Name = "Updates" Or ctl.Name = "text72" Or ctl.Name = "text74" Or ctl.Name = "todaysdate" Or ctl.Name = "Time" Then GoTo TryNextC ' Skip Updates field.

If ctl.Value <> ctl.OldValue Then
MyForm!Updates = MyForm!Updates & Chr(13) & Chr(10) & " " & ctl.Name & ": Changed from: " & ctl.OldValue & " to: " & ctl.Value
End If
End Select
TryNextC:
Next ctl
End Sub
Code:
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)

Forum statistics

Threads
1,221,614
Messages
6,160,839
Members
451,673
Latest member
wella86

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top