The code was exiting the subroutine due to a control which triggered the "operation is not supported for this type of object". I had to add a line of code to check for visible, enabled and locked fields.
Here is the line of code..
If ctl.Visible And ctl.Enabled And Not ctl.Locked then
Here is the line of code in context.
For Each ctl In frm.Controls
'Avoid labels and other controls with Value property.
If .ControlType = acTextBox Or .ControlType = acComboBox Or .ControlType = acListBox Then
If ctl.Visible And ctl.Enabled And Not ctl.Locked Then
If .Value .OldValue Or (IsNull(.OldValue) And Not IsNull(.Value)) Or (IsNull(.Value) And Not IsNull(.OldValue)) Then
varBefore = .OldValue
varAfter = .Value
strControlName = .Name
'Build INSERT INTO statement.
strSQL = "INSERT INTO " _
& "tblAudit (EditDate, User, RecordID, SourceTable, " _
& " SourceField, BeforeValue, AfterValue, ComputerName, UserDomain, UserProfile) " _
& "VALUES (Now()," _
& cDQ & CurrentUser() & cDQ & ", " _
& cDQ & recordid.Value & cDQ & ", " _
& cDQ & frm.RecordSource & cDQ & ", " _
& cDQ & .Name & cDQ & ", " _
& cDQ & varBefore & cDQ & ", " _
& cDQ & varAfter & cDQ & ", " _
& cDQ & Environ("ComputerName") & cDQ & ", " _
& cDQ & Environ("UserDomain") & cDQ & ", " _
& cDQ & Environ("UserProfile") & cDQ & ")"
'View evaluated statement in Immediate window.
Set ctl = Nothing
Keep Up with TechRepublic