I am new to Access VBA and I am stuck in what I think a "Language Limitation". I have a collection of Items and I want to copy some of its items in a new collection depending on the condition and then work on that new collection. But the problem is that if I change or remove anything from that new collection, it gets changed in the previous collection also. But I dont want that to happen as it would be again used as it is in next iteration.
The code which I have used to make the new collection is:
Private Function ReturnSubCollection(TotalCollection As Collection, workIDs As String) As Collection
Dim collWorkIDs As Collection
Dim itemCount As Integer
Dim obj As Object
For itemCount = 1 To TotalCollection.count
If InStr(1, workIDs, TotalCollection.item(itemCount).Work_ID) > 0 Then
Set obj = TotalCollection.item(itemCount)
If collWorkIDs Is Nothing Then Set collWorkIDs = New Collection
collWorkIDs.Add obj
End If
Next
Set ReturnSubCollection = collWorkIDs
End Function