A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Database Design
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Can a collection be wrapped in access?



 
 
Thread Tools Display Modes
  #1  
Old February 8th, 2005, 02:27 PM
Hector Cabrera via AccessMonster.com
external usenet poster
 
Posts: n/a
Default 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  
Old February 8th, 2005, 04:02 PM
onedaywhen
external usenet poster
 
Posts: n/a
Default


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  
Old February 9th, 2005, 12:54 PM
Hector Cabrera via AccessMonster.com
external usenet poster
 
Posts: n/a
Default

Thanks !

I did exactly what you said and it worked !

Thanks again !

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




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

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


All times are GMT +1. The time now is 05:04 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.