In the beforeUpdate event of a data entry form i call thefunction AuditTrail as dispayed herebelow. When this code runs i get the errormessage : Error #3251 with text in the dutch language , of wich i tried to give the translation in the titl of this thread.
Ca anyone telle me what's going on. (the field "udates" is part of the attached table that serves as recordset for the form.)
Dim Mededeling As String
Function AuditTrail()
On Error GoTo Err_Handler
Dim strUser, strClear As String
strUser = fOSUserName
' carriage return and clear -- will insert a blank line into
' each entry. remove "strClear" from any place that you do
' not want the blank line in the memo field.
strClear = Chr(13) & Chr(10)
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 & strClear & _
"Wijzigingen aangebracht op " & Now & " door " & fOSUserName() & ";"
'If new record, record it in audit trail and exit sub.
If MyForm.NewRecord = True Then
MyForm!Updates = "Record aangemaakt op " & Now & " door " _
& fOSUserName() & strClear
Else
'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, _
acCheckBox
' Skip Updates field.
If C.Name <> "Updates" Then
' skip DateChange field. added by ken nichols
If C.Name <> "DateChange" Then
' If control was previously Null, record "previous
' value was blank."
If IsNull(C.OldValue) Or C.OldValue = "" Then
MyForm!Updates = MyForm!Updates & strClear _
& C.Name & "--vorige waarde was " _
& " blanco" & strClear
' indien het besturingselement een vorige warde bezat , noteer deze waarde
ElseIf C.Value <> C.OldValue Then
MyForm!Updates = MyForm!Updates & strClear _
& C.Name & "==vorige waarde " _
& "was: " & Chr(34) & C.OldValue & Chr(34) _
& strClear
' If control is DateChange, don't update.
End If
End If
End If
End Select
Next C
End If
TryNextC:
Exit Function
Err_Handler:
Mededeling = foutbericht("Audittrail", "modAudit", Err.Number)
Resume TryNextC
End Function
Ca anyone telle me what's going on. (the field "udates" is part of the attached table that serves as recordset for the form.)
Dim Mededeling As String
Function AuditTrail()
On Error GoTo Err_Handler
Dim strUser, strClear As String
strUser = fOSUserName
' carriage return and clear -- will insert a blank line into
' each entry. remove "strClear" from any place that you do
' not want the blank line in the memo field.
strClear = Chr(13) & Chr(10)
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 & strClear & _
"Wijzigingen aangebracht op " & Now & " door " & fOSUserName() & ";"
'If new record, record it in audit trail and exit sub.
If MyForm.NewRecord = True Then
MyForm!Updates = "Record aangemaakt op " & Now & " door " _
& fOSUserName() & strClear
Else
'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, _
acCheckBox
' Skip Updates field.
If C.Name <> "Updates" Then
' skip DateChange field. added by ken nichols
If C.Name <> "DateChange" Then
' If control was previously Null, record "previous
' value was blank."
If IsNull(C.OldValue) Or C.OldValue = "" Then
MyForm!Updates = MyForm!Updates & strClear _
& C.Name & "--vorige waarde was " _
& " blanco" & strClear
' indien het besturingselement een vorige warde bezat , noteer deze waarde
ElseIf C.Value <> C.OldValue Then
MyForm!Updates = MyForm!Updates & strClear _
& C.Name & "==vorige waarde " _
& "was: " & Chr(34) & C.OldValue & Chr(34) _
& strClear
' If control is DateChange, don't update.
End If
End If
End If
End Select
Next C
End If
TryNextC:
Exit Function
Err_Handler:
Mededeling = foutbericht("Audittrail", "modAudit", Err.Number)
Resume TryNextC
End Function