Problem with archives in VBA

Problem with archives in VBA

Hello!
I'm trying to display a graph, using an archive. The values and the date come from an Oracle database and must be displayed at the right time.
Everything seems to work, except the ApplyChanges
VBA Code:

Public Sub ModifyArchive()
Dim obArchive As Archive
Dim obArchiveVariable As ArchiveVariable
Dim obArchiveFilter As ArchiveFilter
Dim obArchiveFilterVariable As ArchiveFilterVariable
Dim obArchiveValues As ArchiveValues
Dim vStart As Variant 'Filter start time...
Dim vEnd As Variant 'Filter end time...
Dim idx As Integer

On Error GoTo err:
Set obArchive = thisProject.Archives.Item("COURBE_PREV_67")
Set obArchiveVariable = obArchive.ArchiveVariables.Item(0)
Set obArchiveFilter = obArchive.ArchiveFilters.CreateArchiveFilter
StartDate = "01/09/2009 00:00:00"
EndDate = "01/09/2029 00:00:00"
vStart = DateDiff("s", vDateRef, StartDate)
vEnd = DateDiff("s", vDateRef, EndDate)
obArchiveFilter.StartTime = vStart
obArchiveFilter.endTime = vEnd
'SPONT state
obArchiveFilter.StatusBit = &HFFFFFFFF
obArchiveFilter.StatusMask = Not &H40000
obArchiveFilter.AddArchiveVariable obArchiveVariable
obArchiveFilter.Query
Set obArchiveFilterVariable = obArchiveFilter.ArchiveFilterVariables.Item(0)
Set obArchiveValues = obArchiveFilterVariable.ArchiveValues
' obArchiveValues contains the current values from the archive
' we replace these values with the CurveArray vector values
For idx = 0 To nbValues - 1
obArchiveValues.Item(idx).Time = dateUTC(TimeArray(idx))
obArchiveValues.Item(idx).Value = CurveArray(idx)
obArchiveValues.Item(idx).SetModified
Next idx
obArchiveFilter.ApplyChanges
err:
Set obArchiveFilterVariable = Nothing
Set obArchiveVariable = Nothing
Set obArchiveValues = Nothing
Set obArchive = Nothing
End Sub

Thanks if you can fix this problem!

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