Dim Date1 As String Dim period1 As String Dim Date2 As String Dim period2 As String Dim Date3 As String Dim period3 As String '***************************Attention: Update the months manually - Add the current month and exclude the oldest. Sub Main i = 1 Do While ( Date1= "" And i < 2) period1 = InputBox("Please enter the previous business period(MMMYY)") Date1 = period1 laenge = Len(period1) If laenge <> 5 Then MsgBox("The previous business period is not correct.") End If i = i + 1 Loop j = 1 Do While ( Date2= "" And j < 2) period2 = InputBox("Please enter the current business period(MMMYY)") Date2 = period2 laenge = Len(period2) If laenge <> 5 Then MsgBox("The current business period is not correct.") End If j = j + 1 Loop k = 1 Do While ( Date3= "" And k < 2) period3 = InputBox("Please enter the period to be deleted(MMMYY)") Date3 = period3 laenge = Len(period3) If laenge <> 5 Then MsgBox("The period to be deleted is not correct.") End If k = k + 1 Loop ' KPI ASL Historical Results-KPI1 Call JoinDatabase1() 'KPI ASL Historical Results-KPI1.IMD Call ModifyField1() 'KPI ASL Historical Result KPI1.IMD Call RemoveField() End Sub '*********KPI ASL Historical Results-KPI1 ' Datei: Dateien verbinden Function JoinDatabase1 Set db = Client.OpenDatabase("KPI ASL Historical Results KPI1 " & Date1 & ".IMD") Set task = db.JoinDatabase task.FileToJoin "Result_ASL_KPIs.IMD" task.IncludeAllPFields task.AddSFieldToInc "KPI_1" task.AddMatchKey "COMPANY_CODE", "BUKRS", "A" task.CreateVirtualDatabase = False dbName = "KPI ASL Historical Results KPI1 " & Date2 & ".IMD" task.PerformTask dbName, "", WI_JOIN_ALL_IN_PRIM Set task = Nothing Set db = Nothing Client.OpenDatabase (dbName) End Function ' Feld ändern Function ModifyField1 Set db = Client.OpenDatabase("KPI ASL Historical Results KPI1 " & Date2 & ".IMD") Set task = db.TableManagement Set field = db.TableDef.NewField field.Name = Date2 field.Description = "" field.Type = WI_NUM_FIELD field.Equation = "" field.Decimals = 0 task.ReplaceField "KPI_1", field task.PerformTask Set task = Nothing Set db = Nothing Set field = Nothing End Function 'Feld entfernen Function RemoveField Set db = Client.OpenDatabase("KPI ASL Historical Results KPI1 " & Date2 & ".IMD") Set task = db.TableManagement task.RemoveField """& Date3 &""" task.PerformTask Set task = Nothing Set db = Nothing End Function