Sub PurgeTestRuns() ' Purge runs from a single test set 'This procedure purges all tests more than ' two days old from test set f1_ts1, but keeps ' the last two runs of every test, even if they ' are older than two days. Dim TSetFact As TestSetFactory Dim tsFilter As TDFilter Dim KeepLastCount As Long Dim DateUnit As Variant Dim NumOfDateUnits As Long Dim PurgeStepsOnly As Boolean ' Get a test set factory filter. 'tdc is the global TDConnection object. Set TSetFact = tdc.TestSetFactory Set tsFilter = TSetFact.Filter ' Act only on test set "f1_ts1." ' SELECT * FROM RUN WHERE RN_CYCLE_ID = ' (SELECT CY_CYCLE_ID FROM CYCLE WHERE CY_CYCLE LIKE 'f1_ts1') tsFilter.Filter("CY_CYCLE") = """f1_ts1""" Debug.Print tsFilter.Text ' [Filter]{ ' TableName:CYCLE, ' ColumnName:CY_CYCLE, ' LogicalFilter:"\"f1_ts1\"", ' VisualFilter:"\"f1_ts1\"", ' NO_CASE: ' } KeepLastCount = 2 'Keep at least 2 of each test's runs DateUnit = 1 'Days NumOfDateUnits = 2 'Purge starting 2 days ago PurgeStepsOnly = False ' Purge both the runs and steps. '------------------------------------------------------ ' Purge the runs. tdc.PurgeRuns tsFilter.Text, _ KeepLastCount, _ DateUnit, _ NumOfDateUnits, _ PurgeStepsOnly End Sub