Hey,
Im in the process of adapting the audit trail that was posted on here a few years back now by 'ghudson'. the problem that i have with it is that i get an error message when i change the values of combo boxes - "'Operation is not supported for this type of object." I did abit of digging on this problem but i cant find the mircrosoft site that told me why it wouldnt work. However the solution was to create a recordsetclone on the Current Event to identify the before value (which is the bit that will not work according to microsoft). Ive set this up fine on the form...
The problem i have is when i call the function 'GetBeforeValue' from the module. Here is the relevent code from the module...
FieldBeforeValue then gets populated with the before value of each field in the form which is used to then insert into a table.
However when i do make a change i get the following error message
run-Time Error 2465
Application-defined or Object-defined error
I've also had Object not defined error when i was trying to fix it. The error occurs on 'FieldBeforeValue = MyForm.GetBeforeValue(Ctl.Name)'.
Anybody have any ideas where i might be going wrong?
In short im trying to call a function on a form from a module and pass it a control name (such as the combo box name) and this then returns the value of the control before it was changed using the recordsetclone.
Im in the process of adapting the audit trail that was posted on here a few years back now by 'ghudson'. the problem that i have with it is that i get an error message when i change the values of combo boxes - "'Operation is not supported for this type of object." I did abit of digging on this problem but i cant find the mircrosoft site that told me why it wouldnt work. However the solution was to create a recordsetclone on the Current Event to identify the before value (which is the bit that will not work according to microsoft). Ive set this up fine on the form...
Code:
Option Compare Database
Dim rs As Recordset
Private Sub Form_BeforeUpdate(Cancel As Integer)
Call Audit_Trail(Me, Control_Ref)
End Sub
Private Sub Form_Current()
Set rs = Me.RecordsetClone
rs.Bookmark = Me.Bookmark
End Sub
Public Function GetBeforeValue(CurrentFieldName As Control) As String
GetBeforeValue = rs![CurrentFieldName]
End Function
The problem i have is when i call the function 'GetBeforeValue' from the module. Here is the relevent code from the module...
Code:
Public Function Audit_Trail(MyForm As Form, recordid As Control)
....
Dim Ctl As Control
Dim FieldBeforeValue As String
...
FieldBeforeValue = MyForm.GetBeforeValue(Ctl.Name)
FieldBeforeValue then gets populated with the before value of each field in the form which is used to then insert into a table.
However when i do make a change i get the following error message
run-Time Error 2465
Application-defined or Object-defined error
I've also had Object not defined error when i was trying to fix it. The error occurs on 'FieldBeforeValue = MyForm.GetBeforeValue(Ctl.Name)'.
Anybody have any ideas where i might be going wrong?
In short im trying to call a function on a form from a module and pass it a control name (such as the combo box name) and this then returns the value of the control before it was changed using the recordsetclone.