Audit Trail - Tabbed Control

tucker61

Registered User.
Local time
Yesterday, 22:07
Joined
Jan 13, 2008
Messages
341
I have set up a new form with a Tab Control, that contains 5 tabs.

On most of my forms in my database use the below code to track changes to fields that are Tagged ?
If I Tag the Tab Control, I get error 2427 - You entered a expression that has no value.
or error 438 - Object does not support this property or Method
If I tag the subforms then this does not log the edited data.

Any thoughts ?

Code:
 Call AuditChanges("Unique_ID", "EDIT", Me)
My Tab control is called TabCtl28
Any advice on how i can track the other Tabs (Tab 1 seems to be logged)

Code:
Sub AuditChanges(IDField As String, UserAction As String, pMyForm As Form)

   On Error GoTo AuditChanges_Err
    Dim cnn As ADODB.Connection
    Dim rst As ADODB.Recordset
    Dim ctl As Control
    Dim datTimeCheck As Date
    Dim strUserID As String

    Set cnn = CurrentProject.Connection
    Set rst = New ADODB.Recordset
    rst.Open "SELECT * FROM tblAuditTraillog", cnn, adOpenDynamic, adLockOptimistic
    datTimeCheck = Now()
    strUserID = GetLongName
            
            For Each ctl In pMyForm.Controls
                If ctl.Tag = "Audit" Or ctl.Tag = "Audit;Lock" Or ctl.Tag = "Req;Audit" Then
                'Debug.Print ctl.Name
                'Debug.Print ctl.Value
               ' If Nz(ctl.OldValue, "") <> "" Then
                            If Nz(ctl.Value) <> Nz(ctl.OldValue) Then
                                With rst
                                    .AddNew
                                    ![DateTime] = datTimeCheck
                                    ![UserName] = strUserID
                                    ![FormName] = pMyForm.Name
                                    ![Action] = UserAction
                                    ![RecordID] = pMyForm(IDField).Value
                                    ![FieldName] = ctl.ControlSource
                                    ![OldValue] = ctl.OldValue
                                    ![NewValue] = ctl.Value
                                    .Update
                                End With
                            End If
                        End If
               ' End If
            Next ctl

AuditChanges_Exit:
    On Error Resume Next
    rst.Close
    cnn.Close
    Set rst = Nothing
    Set cnn = Nothing
    Exit Sub
AuditChanges_Err:
'Debug.Print ctl.Name
'Debug.Print ctl.Value
    Call LogError(Err.Number, Err.Description, "AuditTrial", "")
    Resume AuditChanges_Exit
End Sub
 
The Tab control is simply a page extension to the form, it's not a data-bearing control.
You will have to tag the controls on the tab pages, not the page itself.
 

Users who are viewing this thread

Back
Top Bottom