If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Can a collection be wrapped in access?
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 |
#2
|
|||
|
|||
Hector Cabrera via AccessMonster.com wrote: 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? Export the class module to disk, open in a text editor and add the hidden lines e.g. Public Property Get NewEnum() As IUnknown Attribute NewEnum.VB_UserMemId = -4 Attribute NewEnum.VB_MemberFlags = "40" Set NewEnum = myCol.[_NewEnum] End Property Save and re-import to the vba project. The procedure will not be hidden in VBA but you may as well leave in Attribute in for next time g. Jamie. -- |
#3
|
|||
|
|||
Thanks !
I did exactly what you said and it worked ! Thanks again ! -- Message posted via http://www.accessmonster.com |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Access Error Message when opening database | eah | General Discussion | 3 | January 26th, 2005 10:04 AM |
Hiding Access | Mark A. Sam | Using Forms | 4 | December 1st, 2004 09:09 PM |
WORD XP mail-merge FAILS using ACCESS Query | SueMackay | Mailmerge | 1 | November 23rd, 2004 01:03 PM |
MICROSOFT INVESTING HEAVILY IN ACCESS | Mike Painter | General Discussion | 39 | October 15th, 2004 03:56 PM |
Access 2000 DB in Access 2002 | Tony_VBACoder | General Discussion | 2 | July 28th, 2004 01:23 AM |