AnsweredAssumed Answered

How to use Visual Basic to Multiple-value functions

Question asked by Ethan_GranBio on Oct 3, 2019
Latest reply on Oct 4, 2019 by Steve Boyko

I'm trying to use the VBPISamDat function that comes along with the PI add on in Excel. But I've been getting an error that shows as follows: "Failed to retrieve events from server.  [-11128] Number of requested events exceeded the maximum allowed".  I haven't been able to find any discussion forum for this error [-11128] online and haven't been able to resolve it myself. I don't believe that my code is attempting to pull more than the maximum allowed events, as the regular PI function PISampData works perfectly.  I've added a simplified bit of the code I'm trying to execute, has anyone else had this problem and know a solution?


sub test()

Dim ws As Worksheet
Dim datalink As Object
Dim startdate As Date
Dim enddate As Date

Set datalink = New PIPC32Class
Set ws = Application.ThisWorkbook.Sheets("Sheet1")

startdate = ws.Cells(2, 1)
Tag = ws.Cells(4, 1)
enddate = ws.Cells(3, 1)
outcode = ws.Cells(5, 1)


ws.Cells(3, 4) = datalink.VBPISampDat(Tag, startdate, enddate, TimeSerial(8, 0, 0), outcode)

End Sub