Sub XX_Set_Events ()
    On Error Resume Next
'   ---------------------------------------------------------------
'   Ersetzt alle allf. "Ereignisprozeduren" durch "Event procedure"
'   ---------------------------------------------------------------
    Dim IWrk As WorkSpace, IDbs As Database
    Dim ICont As Container, IForm As Form, IRep As Report
    Dim IField As Control, IInt_YN As Single, IVar_Name As Variant
    Dim Int_CN1 As Integer, Int_CN2 As Integer, Int_CN3 As Integer
    Dim IStr_Old As String, IStr_New As String
'   ---------------------
'   Set Old and New Terms
'   ---------------------
    IStr_Old = "[Ereignisprozedur]"
    IStr_New = "[Event procedure]"

    Set IWrk = DBEngine.Workspaces(0)
    Set IDbs = IWrk.Databases(0)
'   -----
'   Forms
'   -----
    If Forms.count = 0 Then
        IInt_YN = MsgBox("You want me to loop thru all your forms?", 36, "Correct Event procedures")
    Else
        IInt_YN = 0
    End If
    
    If IInt_YN = 6 Then
        Set ICont = IDbs.containers("Forms")
        For Int_CN1 = 0 To ICont.Documents.count - 1
            IVar_Name = ICont.Documents(Int_CN1).Name
            DoCmd OpenForm IVar_Name, A_DESIGN
            Set IForm = Forms(IVar_Name)
'           --------------------------
'           Outer Loop thru Properties
'           --------------------------
            For Int_CN3 = 0 To IForm.properties.count - 1
                If IForm.properties(Int_CN3).Value = IStr_Old Then
                    If Err = 0 Then
                        Debug.Print "Old: " & IForm.properties(Int_CN3).Value
                        IForm.properties(Int_CN3).Value = IStr_New
                        Debug.Print "New: " & IForm.properties(Int_CN3).Value
                    End If
                End If
            Next
'           --------------------------
'           Inner Loop thru Properties
'           --------------------------
            For Int_CN2 = 0 To IForm.count - 1
                Set IField = IForm(Int_CN2)
                For Int_CN3 = 0 To IField.properties.count - 1
                    If IField.properties(Int_CN3).Value = IStr_Old Then
                        If Err = 0 Then
                            Debug.Print "Old: " & IField.properties(Int_CN3).Value
                            IField.properties(Int_CN3).Value = IStr_New
                            Debug.Print "New: " & IField.properties(Int_CN3).Value
                        End If
                    End If
                Next
            Next
            
            DoCmd Close A_FORM, IVar_Name
        Next
    End If
'   -------
'   Reports
'   -------
    If MsgBox("You want me to loop thru all your reports?", 36, "Correct Event procedures") = 6 Then
        Set ICont = IDbs.containers("Reports")
    
        For Int_CN1 = 0 To ICont.Documents.count - 1
            IVar_Name = ICont.Documents(Int_CN1).Name
            DoCmd OpenReport IVar_Name, A_DESIGN
            Set IRep = Reports(IVar_Name)
'           --------------------------
'           Outer Loop thru Properties
'           --------------------------
            For Int_CN3 = 0 To IRep.properties.count - 1
                If IRep.properties(Int_CN3).Value = IStr_Old Then
                    If Err = 0 Then
                        Debug.Print "Old: " & IRep.properties(Int_CN3).Value
                        IRep.properties(Int_CN3).Value = IStr_New
                        Debug.Print "New: " & IRep.properties(Int_CN3).Value
                    End If
                End If
            Next
'           --------------------------
'           Inner Loop thru Properties
'           --------------------------
            For Int_CN2 = 0 To IRep.count - 1
                Set IField = IRep(Int_CN2)
                For Int_CN3 = 0 To IField.properties.count - 1
                    If IField.properties(Int_CN3).Value = IStr_Old Then
                        If Err = 0 Then
                            Debug.Print "Old: " & IField.properties(Int_CN3).Value
                            IField.properties(Int_CN3).Value = IStr_New
                            Debug.Print "New: " & IField.properties(Int_CN3).Value
                        End If
                    End If
                Next
            Next
            
            DoCmd Close A_REPORT, IVar_Name
        Next
    End If
End Sub

