d1trupinoy
Technical User
I am trying to build a module that will write a log everytime Dirty is true. Right now I just call this module from various forms using the Before Update event. Some forms it works fine but other forms cause an error 3251 - Operation is not supported for this type of object. It will happen on a text box, combo box, etc. I have no idea why. Why will some forms work fine and others not work fine. The error highlights "ctrl.OldValue" as the object that "Operation is not supported for this type of object". Some combo boxes work with this code while others cause the 3251 error. Some text boxes work fine while others cause the error. Forms are based on queries, tables, etc. Any idea or thought would be greatly appreciated.
Sub LogGenerator(FormFocus As Form)
If FormFocus.Dirty Then
MsgBox "Data has changed"
Dim ctrl As Control
For Each ctrl In FormFocus.Controls
If ctrl.ControlType = acTextBox Then
If ctrl.Visible = True Then
MsgBox "acTextBox IF Statement"
MsgBox (ctrl.Name)
MsgBox ("ctrl.Value = " & ctrl.Value)
MsgBox ("ctrl.OldValue = " & ctrl.OldValue)
If ctrl.Value <> ctrl.OldValue Then
MsgBox ctrl.Name & " has changed to " & ctrl.Value
End If
End If
End If
If ctrl.ControlType = acComboBox Then
If ctrl.Visible = True Then
MsgBox "acComboBox IF Statement"
MsgBox (ctrl.Name)
MsgBox ("ctrl.Value = " & ctrl.Value)
MsgBox ("ctrl.OldValue = " & ctrl.OldValue)
If ctrl.Value <> ctrl.OldValue Then
MsgBox ctrl.Name & " has changed to " & ctrl.Value
End If
End If
End If
If ctrl.ControlType = acCheckBox Then
If ctrl.Visible = True Then
MsgBox "acCheckBox IF Statement"
MsgBox (ctrl.Name)
MsgBox ("ctrl.Value = " & ctrl.Value)
MsgBox ("ctrl.OldValue = " & ctrl.OldValue)
If ctrl.Value <> ctrl.OldValue Then
MsgBox ctrl.Name & " has changed to " & ctrl.Value
End If
End If
End If
Next ctrl
Else
MsgBox "OK"
'Refresh
End If
End Sub
Sub LogGenerator(FormFocus As Form)
If FormFocus.Dirty Then
MsgBox "Data has changed"
Dim ctrl As Control
For Each ctrl In FormFocus.Controls
If ctrl.ControlType = acTextBox Then
If ctrl.Visible = True Then
MsgBox "acTextBox IF Statement"
MsgBox (ctrl.Name)
MsgBox ("ctrl.Value = " & ctrl.Value)
MsgBox ("ctrl.OldValue = " & ctrl.OldValue)
If ctrl.Value <> ctrl.OldValue Then
MsgBox ctrl.Name & " has changed to " & ctrl.Value
End If
End If
End If
If ctrl.ControlType = acComboBox Then
If ctrl.Visible = True Then
MsgBox "acComboBox IF Statement"
MsgBox (ctrl.Name)
MsgBox ("ctrl.Value = " & ctrl.Value)
MsgBox ("ctrl.OldValue = " & ctrl.OldValue)
If ctrl.Value <> ctrl.OldValue Then
MsgBox ctrl.Name & " has changed to " & ctrl.Value
End If
End If
End If
If ctrl.ControlType = acCheckBox Then
If ctrl.Visible = True Then
MsgBox "acCheckBox IF Statement"
MsgBox (ctrl.Name)
MsgBox ("ctrl.Value = " & ctrl.Value)
MsgBox ("ctrl.OldValue = " & ctrl.OldValue)
If ctrl.Value <> ctrl.OldValue Then
MsgBox ctrl.Name & " has changed to " & ctrl.Value
End If
End If
End If
Next ctrl
Else
MsgBox "OK"
'Refresh
End If
End Sub