Results 1 to 4 of 4
  1. #1
    Juans is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2015
    Posts
    2

    Audit Trail Code - Error 3251

    Dear friends,

    I am building up a database which stores various information, being text and numeric. In order to facilitate matters for the users (and to standardize data), I have created combo boxes which enable the users to quickly choose particular categories to tag their record. I have also included an audit trail in order to enable users to see the history of such record (and for internal audit reasons too!). Whilst the code works excellently on standard text box and memos, it is prompting an error when the data in the combo boxes is changed, being Error #:3251. I have tried researching this problem, yet I haven't found a solution !! The code I am using is as follows:



    Code:
    Function AuditTrail() As Boolean
     On Error GoTo Err_Handler
     Dim MyForm As Form, c As Control, xName As String
     Set MyForm = Screen.ActiveForm
     'Set date and current user if form has been updated.
     MyForm!Updates = MyForm!Updates & Chr(13) & Chr(10) & _
     "<<Changes made on>> " & Date & " " & Time & " by " & [Forms]![Switchboard]![Text7] & ";"
     'If new record, record it in audit trail and exit sub.
     If MyForm.NewRecord = True Then
        MyForm!Updates = MyForm!Updates & Chr(13) & Chr(10) & _
        "New Record """
     End If
     'Check each data entry control for change and record
     'old value of Control.
     For Each c In MyForm.Controls
        'Only check data entry type controls.
        Select Case c.ControlType
        Case acTextBox, acComboBox, acListBox, acOptionGroup
        ' Skip Updates field.
            If c.Name <> "Updates" Then
                ' If control was previously Null, record "previous
                ' value was blank."
                If IsNull(c.OldValue) Or c.OldValue = "" Then
                    MyForm!Updates = MyForm!Updates & Chr(13) & _
                    Chr(10) & c.Name & "--previous value was blank"
                ' If control had previous value, record previous value.
                ElseIf IIf(IsNull(c.Value), "", c.Value) <> c.OldValue Then
                   MyForm!Updates = MyForm!Updates & Chr(13) & Chr(10) & _
                   c.Name & "==previous value was " & c.OldValue
                End If
            End If
        End Select
     Next c
    TryNextC:
     Exit Function
    Err_Handler:
     If Err.Number <> 64535 Then
     MsgBox "Error #: " & Err.Number & vbCrLf & "Description: " & Err.Description
     End If
     Resume TryNextC
     End Function


    Do you have an idea how I can address this Error on the combo boxes ?? As this is driving me crazy!!

    Thanks for your help!

    Juans
    Last edited by June7; 01-04-2015 at 12:02 PM.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    One way to debug is to temporarily comment out the "On Error..." line and run the code. You should be offered a Debug option when it errors that will take you to the exact line with the problem. It would help to know the text of the error too.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Juans is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2015
    Posts
    2
    Hi pbaldy,


    The error relates to the following :

    Select Case c.ControlType
    Case acTextBox, acComboBox, acListBox, acOptionGroup

    Yet, I cannot exclude this part as then no data would be recorded.

    Thanks.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Those lines would execute for any data type, so I would expect an error all the time. Can you post the db here with how to recreate the error?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Audit Trail into Subform
    By AdamMVRRS in forum Access
    Replies: 10
    Last Post: 02-07-2014, 10:16 AM
  2. Replies: 2
    Last Post: 02-09-2013, 12:39 PM
  3. Audit Trail
    By bigroo in forum Programming
    Replies: 4
    Last Post: 02-22-2012, 07:55 PM
  4. audit trail
    By slimjen in forum Forms
    Replies: 1
    Last Post: 10-13-2011, 01:52 PM
  5. Audit trail question #2
    By jpkeller55 in forum Access
    Replies: 9
    Last Post: 09-13-2010, 05:55 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums