Error #3251 this process is not available for this type of object

odrap

Registered User.
Local time
Today, 07:36
Joined
Dec 16, 2008
Messages
156
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
 
I would make the one change in Red.
Code:
Function AuditTrail()
   On Error GoTo Err_Handler

   Dim strUser [COLOR="Red"][B]As String[/B][/COLOR], 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
...then ask you which line does the debugger highlight? BTW, the Code tags (the # button) make it easier to read.
 

Users who are viewing this thread

Back
Top Bottom