Archivdaten löschen

Archivdaten löschen

Hallo,
ich möchte unserm Kunden ermöglichen Archivdaten (Chargenprotokolle) zu löschen. Projektiert ist ein Archiv (BS) das einmal am Tag gespeichert wird und ereignisgesteuert aufzeichnet. Ich verwende Zenon 7.00.
Der folgende Code läuft fehlerfrei ab und es werden auch die richtigen Variablen und deren Werte dem Archivfilter hinzugefügt. Die Varialen und Werte hab ich mir testweise anzeigen lassen. Leider funktioniert die Anweisung boResult = zArvBSValues.DeleteArchiveValue(k) nicht. Woran kann das liegen?
VBA Code:

'löschen eines Archivdatensatzes
Public Sub BatchListDeleteBatch()
Dim boResult As Boolean
Dim i As Integer
Dim k As Integer
Dim lCnt As Long
Dim dbStartTime As Double
Dim dbEndTime As Double
Dim strI1 As String
Dim zArvBS As Archive
Dim zArvBSFilter As ArchiveFilter
Dim zArvBSVars As ArchiveFilterVariables
Dim zArvBSVar As ArchiveFilterVariable
Dim zArvBSValues As ArchiveValues
On Error GoTo Err

'Objekt von dem Archiv Batch Start und End"
Set zArvBS = thisProject.Archives.Item("BATCH START")
'neuen Archivfilter anlegen
Set zArvBSFilter = zArvBS.ArchiveFilters.CreateArchiveFilter
'alle Archivvaribalen aus dem Archiv BS dem Archivfilter hinzufügen
For i = 0 To zArvBS.ArchiveVariables.Count - 1
zArvBSFilter.AddArchiveVariable zArvBS.ArchiveVariables.Item(i)
Next i

'Chargenliste durchsuchen und Start- und Endzeit erfassen
For i = 1 To Constant.iLIST50
strI1 = CStr(i)
'Ausgewählte Charge suchen
If thisProject.oVarCon.Item("l.Archiv.Batch.List.boActive[" & strI1 & "]").value = 1 Then
'Startzeit und Endzeit
dbStartTime = thisProject.oVarCon.Item("l.Archiv.Batch.List.Time.dStart[" & strI1 & "]").value
dbEndTime = thisProject.oVarCon.Item("l.Archiv.Batch.List.Time.dEnd[" & strI1 & "]").value
GoTo NextStep
End If
Next i
NextStep:
'Zeiten den Archivfiltern übergeben
zArvBSFilter.StartTime = dbStartTime
zArvBSFilter.EndTime = dbEndTime
'Den Archivfilter mit den entsprechenden Zeiten aktivieren
Set zArvBSVars = zArvBSFilter.Query

'Schleife über alle Archivvariablen aus dem Archiv BS
For i = 0 To zArvBSVars.Count - 1
Set zArvBSVar = zArvBSVars.Item(i)
Set zArvBSValues = zArvBSVar.ArchiveValues
'Schleife über alle Werte zu der Archivvariable(normal ist hier nur ein Wert vorhanden)
lCnt = zArvBSValues.Count
For k = 0 To lCnt - 1
boResult = zArvBSValues.DeleteArchiveValue(k)
Next k
Set zArvBSVar = Nothing
Set zArvBSValues = Nothing
Next i

Err:
If Err.Number <> 0 Then Call Functions.WriteLogFile("AB.BLDB_1 " & Err.Description)
If Not zArvBS Is Nothing Then Set zArvBS = Nothing
If Not zArvBSFilter Is Nothing Then Set zArvBSFilter = Nothing
If Not zArvBSVars Is Nothing Then Set zArvBSVars = Nothing
If Not zArvBS Is Nothing Then Set zArvBS = Nothing

End Sub


This is a migrated post! Originally posted on 11.03.2014 by user sniggi. Please be aware that information can be outdated.

    Disclaimer

    This document governs the use of our Community Forum. By registering and using the platform, you accept these conditions.

    The COPA-DATA Community Forum serves to encourage the exchange of information and experience about the zenon software between forum users respectively zenon users.

    Please mind that any published information on the Community Forum is the subjective opinion and view based on the experience and the level of knowledge of the author. COPA-DATA does not overtake any responsibility for the content and the accuracy of the shared information.

    Users of the Community Forum are encouraged to share only well-founded experiences and to point out any risks associated with the implementation of proposed solutions to problems. COPA-DATA at its absolute discretion, reserves the right to moderate the forum. In this connection COPA-DATA may remove any information containing false facts, potentially dangerous solutions, bad language or content that may insult, degrade or discriminate others. COPA-DATA may block a non-complying user from forum access if the user violated this provision.

    COPA-DATA reserves the right to change this document from time to time at own discretion.


    Ing. Punzenberger COPA-DATA GmbH
    Karolingerstraße 7b · 5020 Salzburg · Austria
    www.copadata.com