I have a class:
Public store As String
Public group As String
Public code As Long
Public name As String
Public format As Long
Public minQuantity As Long
And simple function:
Private Function addToCollection(ByVal source As Collection, ByRef dest As Collection)
Dim pos As position
For Each pos In source
dest.Add pos
Next pos
End Function
Function addToCollection invokes in this piece of code:
Public Function getPositions(ByRef stores As Collection, ByVal groupName As String, ByVal matrixArray As Variant) As Collection
Dim result As New Collection
Dim groupCol As Integer, formatCol As Integer
groupCol = getColByName(groupName)
formatCol = getColByName(matrix)
Dim filteredByGroupAndFormat As Collection
Dim item As store
For Each item In stores
Set filteredByGroupAndFormat = getPositionsByGroupAndFormat(matrixArray, item.format, formatCol, groupCol, item.name, item.group)
Call addToCollection(filteredByGroupAndFormat, result)
Next item
Set getPositions = result
End Function
for the first time it works and new positions are adding to the dest collection, but for the second invocation, the collection is not changing and method .Add simply doesn't work. Does anyone familiar with the problem?
I expect that dest collection will populate with new positions each time the function calls