Can a collection be wrapped in access?

From: Hector Cabrera via AccessMonster.com (forum_at_AccessMonster.com)
Date: 02/08/05


Date: Tue, 08 Feb 2005 14:27:19 GMT

Goodmorning ! Any help with this issue? How can I set the needed procedure
attributes in access to have a wrapped collection class and not loose the
"For Each...Next" functionality? Am I asking too much of access? This is
what I have in the class:

Option Compare Database
Event addItem(strId As String)
Event removeItem(strId As String)

Public myCol As Collection

Private Sub Class_Initialize()
    Set myCol = New Collection
End Sub

Private Sub Class_Terminate()
    Set myCol = Nothing
End Sub

Public Function Add(Value As Form) As clsParticipant
On Error Resume Next
Dim objItem As New clsParticipant
    objItem.Name = Value("name")
    objItem.Phone = Value("phone")
    objItem.Email = Value("email")
    objItem.Company = Value("company")
myCol.Add objItem, objItem.Name
Set Add = objItem
On Error GoTo 0
End Function

Public Sub remove(strName As String)
    myCol.remove strName
End Sub

Public Function count() As Long
    count = myCol.count
End Function

Public Function Item(ByVal varIndex As Variant) As clsParticipant
    Set Item = myCol.Item(varIndex)
End Function

Public Function NewEnum() As IUnknown
    Set NewEnum = myCol.[_NewEnum]
End Function

-- 
Message posted via http://www.accessmonster.com


Relevant Pages