I'm using some audit code from Martin Greene's webpage and I'm having some difficult with a control that does not allow me to compare the control value and it's oldvalue. The code is below:
Dim cnn As ADODB.Connection
Dim rstAudit As ADODB.Recordset
Dim ctl As Control
Dim datTimeCheck As Date
'Dim strUserID As String
Dim MaxMember_id As Integer
Set cnn = CurrentProject.Connection
Set rstAudit = New ADODB.Recordset
rstAudit.Open "Select * from Audit_Trail", cnn, adOpenDynamic, adLockOptimistic
datTimeCheck = Now()
Select Case UserAction
'existing records
Case "Edit"
For Each ctl In Screen.ActiveForm.Controls
If ctl.Tag = "Audit" Then
If ctl.ControlType = acTextBox Or ctl.ControlType = acComboBox Or ctl.ControlType = acCheckBox Then
'Debug.Print "Old Value is :" & ctl.OldValue
'
Debug.Print "Control Name = " & ctl.Name
Debug.Print "Value is = " & ctl.Value
If Nz(ctl.Value) <> Nz(ctl.OldValue) Then... when the checkbox control in question hits this line, I get the error...."Operations is not supported for this type of object..."
But I use the same control in another form, which runs through this same audit code and it does not complain at all when the code processes the controls of that form. So, why does this control fail at this line now?
With rstAudit
.AddNew
![DateTime] = datTimeCheck
![UserName] = strAccountName
![FormName] = Screen.ActiveForm.Name
![Action] = UserAction
![Record_ID] = MaxMember_id
![FieldName] = ctl.ControlSource
![OldValue] = ctl.OldValue
![NewValue] = ctl.Value
.Update
'Debug.Print "Current values " & UserAction
End With
End If
End If
End If
Next ctl
CementCarver