I've figured out how to add items to a class collection and how to update them, but I need to remove an item from a class collection. I can't seem to get a handle on this and would appreciate any help with it. Below is a sample of the code I have been working on.
Thanks,
Sherry
Dim g_colSummaryRows As New clsSummaryRows
************************************************
Class Module: clsSummaryRows
Public RowName as String
Public ActualQ1Revnue as double
************************************************
Class Module: clsSummaryRows
Public Sub Add(recSummaryRow As clsSummaryRow)
AllSummaryRows.Add recSummaryRow
End Sub
Public Property Get Count() As Long
Count = AllSummaryRows.Count
End Property
Public Property Get items() As Collection
Set items = AllSummaryRows
End Property
Public Property Get item(MyItem As Variant) As clsIncomeStatementRow
Set item = AllSummaryRows(MyItem)
End Property
Public Sub Remove(MyItem As Variant)
AllSummaryRows.Remove (MyItem)
End Sub
**********************************************
Sub RemoveRowfoundInCollection(recIncomeStatementRows as ADODB.Recordset)
if rowname from database matches rowname in collection, I want to remove the item from the collection
With recIncomeStatementRows
End sub
Thanks,
Sherry
Dim g_colSummaryRows As New clsSummaryRows
************************************************
Class Module: clsSummaryRows
Public RowName as String
Public ActualQ1Revnue as double
************************************************
Class Module: clsSummaryRows
Public Sub Add(recSummaryRow As clsSummaryRow)
AllSummaryRows.Add recSummaryRow
End Sub
Public Property Get Count() As Long
Count = AllSummaryRows.Count
End Property
Public Property Get items() As Collection
Set items = AllSummaryRows
End Property
Public Property Get item(MyItem As Variant) As clsIncomeStatementRow
Set item = AllSummaryRows(MyItem)
End Property
Public Sub Remove(MyItem As Variant)
AllSummaryRows.Remove (MyItem)
End Sub
**********************************************
Sub RemoveRowfoundInCollection(recIncomeStatementRows as ADODB.Recordset)
if rowname from database matches rowname in collection, I want to remove the item from the collection
With recIncomeStatementRows
For RowCounter = 1 to .RecordCount
next RowCounter
end with'Check if row is in collection
if g_SummaryRows.count> 0 then
.MoveNext 'go to next IncomeStatementRows recordif g_SummaryRows.count> 0 then
For RecordCounter = 1 to g_SummaryRows.Count
end ifIf !RowName = g_SummaryRows.item(RecordCounter).RowName then
Next RecordCounter 'go to next g_SummaryRows item'Row name was found in collection, so remove item from collection
**How do I remove this item from the collection g_SummaryRows please?**
end if**How do I remove this item from the collection g_SummaryRows please?**
next RowCounter
End sub