I have a function that loops through all of the controls on a form. If the tag says "audit", it tracks the changes made to that field. It's worked fine until now. Now, it is throwing an error of "Operation is not supported for this type of object". When I turn off the error handling, and check the code, for some reason it is feeding the actual field VALUE in as the control name. Any help would be very much appreciated. Here's the code:
Dim rst As Recordset
Dim ctl As Control
Dim datTimeCheck As Date
Dim strUserID As String
Dim dbs As DAO.Database
Dim strSQL As String
Set dbs = CurrentDb
strSQL = "SELECT * FROM ChangeLog"
Set rst = dbs.OpenRecordset(strSQL, dbOpenDynaset, dbSeeChanges)
datTimeCheck = Now()
strUserID = Environ("USERNAME")
For Each ctl In Screen.ActiveForm.Controls
If ctl.Tag = "Audit" Then
If Nz(ctl.Value) <> Nz(ctl.OldValue) Then
With rst
.AddNew
![ChangeTimeStamp] = datTimeCheck
![UserId] = strUserID
![FormName] = Screen.ActiveForm.Name
![LeadID] = Lead
![EstID] = Estimate
![EOINumber] = Order
![InstalID] = Install
![FieldName] = ctl.ControlSource
![FieldValueBeforeChange] = Nz(ctl.OldValue, "Blank")
![FieldValueAfterChange] = Nz(ctl.Value, "Blank")
.Update
End With
End If
End If
Next ctl