none
Operation is not supported for this type of object. 3251 RRS feed

  • Question

  • I added a module to my application to be able to track the changes in forms, it work good in some forms but in my "WorkOrder" form when I change something in form before update it show a message that "Operation is not supported for this type of object. 3251", I close the message and go to another record. It save the change in Audit table , but I don't know what is the message for.

    Option Compare Database
    
    Const cDQ As String = """"
    Sub AuditTrail(frm As Form, recordid As Control)
    'Track changes to data.
    'recordid identifies the pk field's corresponding
    'control in frm, in order to id record.
    Dim ctl As Control
    Dim varBefore As Variant
    Dim varAfter As Variant
    Dim strControlName As String
    Dim strSQL As String
    On Error GoTo ErrHandler
    'Get changed values.
    For Each ctl In frm.Controls
    With ctl
    'Avoid labels and other controls with Value property.
    Select Case ctl.ControlType
    Case acTextBox
        If .Value <> .OldValue Then
        varBefore = .OldValue
        varAfter = .Value
        strControlName = .Name
        'Build INSERT INTO statement.
        strSQL = "INSERT INTO " _
        & "Audit (EditDate, User, RecordID, SourceTable, " _
        & " SourceField, BeforeValue, AfterValue) " _
        & "VALUES (shamsi()," _
        & cDQ & Environ("username") & cDQ & ", " _
        & cDQ & recordid.Value & cDQ & ", " _
        & cDQ & frm.RecordSource & cDQ & ", " _
        & cDQ & .Name & cDQ & ", " _
        & cDQ & varBefore & cDQ & ", " _
        & cDQ & varAfter & cDQ & ")"
        'View evaluated statement in Immediate window.
        Debug.Print strSQL
        DoCmd.SetWarnings False
        DoCmd.RunSQL strSQL
        DoCmd.SetWarnings True
        End If
    Case acComboBox
        If .Value <> .OldValue Then
        varBefore = .OldValue
        varAfter = .Value
        strControlName = .Name
        'Build INSERT INTO statement.
        strSQL = "INSERT INTO " _
        & "Audit (EditDate, User, RecordID, SourceTable, " _
        & " SourceField, BeforeValue, AfterValue) " _
        & "VALUES (shamsi()," _
        & cDQ & Environ("username") & cDQ & ", " _
        & cDQ & recordid.Value & cDQ & ", " _
        & cDQ & frm.RecordSource & cDQ & ", " _
        & cDQ & .Name & cDQ & ", " _
        & cDQ & varBefore & cDQ & ", " _
        & cDQ & varAfter & cDQ & ")"
        'View evaluated statement in Immediate window.
        Debug.Print strSQL
        DoCmd.SetWarnings False
        DoCmd.RunSQL strSQL
        DoCmd.SetWarnings True
        End If
    Case acCheckBox
        If .Value <> .OldValue Then
        varBefore = .OldValue
        varAfter = .Value
        strControlName = .Name
        strSQL = "INSERT INTO " _
        & "Audit (EditDate, User, RecordID, SourceTable, " _
        & " SourceField, BeforeValue, AfterValue) " _
        & "VALUES (shamsi()," _
        & cDQ & Environ("username") & cDQ & ", " _
        & cDQ & recordid.Value & cDQ & ", " _
        & cDQ & frm.RecordSource & cDQ & ", " _
        & cDQ & .Name & cDQ & ", " _
        & cDQ & varBefore & cDQ & ", " _
        & cDQ & varAfter & cDQ & ")"
        'View evaluated statement in Immediate window.
        Debug.Print strSQL
        DoCmd.SetWarnings False
        DoCmd.RunSQL strSQL
        DoCmd.SetWarnings True
        End If
        
    End Select
    End With
    Next
    Set ctl = Nothing
    Exit Sub
    ErrHandler:
    MsgBox Err.Description & vbNewLine _
    & Err.Number, vbOKOnly, "Error"
    End Sub
    


    Regards,

    Friday, December 4, 2015 5:56 PM

All replies

  • Hi. Have you tried stepping through your code? Just curious...
    Friday, December 4, 2015 8:00 PM
  • Hi kvaziri,

    It seems that the code in the three Cases is exactly the same. In that case you can combine the code to one block:

    Select Case ctl.ControlType
    Case acTextBox, acComboBox, acCheckBox
      ...
      ...
    End Select

    Imb.

    Friday, December 4, 2015 8:55 PM
  • Hi Kvaziri,

    Have you fixed the issue now? If not, I suggest that you try to debug the code to see which line of code cause this issue.

    If you still have the issue, you can try to upload a demo data on OneDrive to help us narrow down this issue. And please remove the sensitive information before you uploading.

    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, December 11, 2015 9:37 AM
    Moderator