AnsweredAssumed Answered

Can't get PISubBatches info

Question asked by bartmch on Aug 6, 2015
Latest reply on Jun 7, 2016 by bartmch

Hi everyone,

For every batch within a list of batches I want to retrieve the name, start and end time of the subbatches. Although the variable isn't nothing or empty it would not give me any information (VBA)

Dim PiBatchArray As PIUnitBatchList
Set PiBatchArray = PiSrvr.PIModuleDB.PIUnitBatchSearch(PiStartTime,PiEndTime,"*"+UnitArray(i_Unit)+"*","*"+BatchArray(i_Batch)+"*","*","*","*", Nothing, Nothing, Nothing)
For Each PiBatchN In PiBatchArray
     Set PiSubBatchArray = PiBatchN.PISubBatches
     If Not(PiSubBatchArray Is Nothing) Then
          For Each PiSubBatchN In PiSubBatchArray --> Causing error (ActiveX Automation error. 'Element not found.'
               PiSubBatchN.Name
          Next PiSubBatchN
     End If
Next PiBatchN

When I debug it and type in the next things in the Watch window I get:

1: PiSubBatchArray -> [PISubBatches@0x1a0f1878]

So the PiSubBatchArray isn't nothing (already shown with the if statement in previous code snippet) and is referring to a variable, but when I do:

1: PiSubBatchArray.Count -> ((10091) ActiveX Automation: no such property or method.)

When I try it a different way I also get:

1: PiBatchArray(2).Item(2).PISubBatches.Count -> ((10091) ActiveX Automation: no such property or method.)

 

I remember it was working last time (don't remember the exact method) but forgot to save it

 

Thank you !

Outcomes