This is a routine in a script library. I’ve highlighted where the error occurs. I’ve recompiled all the script in the system - nothing changes. I tried making i and BL() long and double but I see the same error. I’ve also done copy/paste to make sure the BL(i) isn’t a typo.
Any pointers are appreciated.
Doug
Sub BuildActualNestedBOM(_
PN() As Variant, _
Desc() As String, _
PrtQty() As Integer, _
BOMView As NotesView, _
i As Integer, _
BL() As Integer)
'==== i and BL() come in as 0
’ This is a recursive agent that can drill down n levels to build a full blown BOM.
’ This code could probably be modified to display the BOM in an indented fashion by
' logging the number of times each recursive call has been made.
' This is not required for the current implementation.
Dim ThisLevelQty As Integer
Dim TotQty As Integer
Dim dc As NotesDocumentCollection
Dim doc As NotesDocument
Dim J As Integer
Dim IL As Integer 'indent level
Dim ParentQty As Integer
TotQty = 0 'initialize for this pass
ParentQty = PrtQty(i)
IL = BL(i) + 1
Set dc = BOMView.GetallDocumentsByKey(PN(i))
If dc.count = 0 Then
' do nothing as there is no new key
Else
' extend key set
For J = 1 To dc.count
'Get Jth document NextLowerPart
Set doc = dc.getNthdocument(J)
If doc.ComponentNumber(0) = "" Then
'skip it and do not increment the parts list array
Else
i = i + 1
Redim Preserve PN(i)
Redim Preserve PrtQty(i)
Redim Preserve Desc(i)
Redim Preserve BL(i) '====>>> Redim error happens here on the first pass through the code. i has the value of 1
PN(i) = doc.ComponentNumber(0)
Desc(i) = doc.ComponentDescription(0)
ThisLevelQty = doc.ComponentQuantity(0)
BL(i) = IL
TotQty = ParentQty * ThisLevelQty
PrtQty(i) = TotQty
Call BuildActualNestedBOM(PN, Desc, PrtQty,BOMView, i, BL)
End If
Next
End If
End Sub