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