View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Andrew[_16_] Andrew[_16_] is offline
external usenet poster
 
Posts: 66
Default RaiseEvent from a class contained in a 2nd class collection?

I have two objects: cField and cSink. There are many Fields and
pointers to these are stored in a collection within the cSink objects.
When a change is made in the cField object I need it to trigger an
event in the cSink object. I have this almost correct but although
the fields are being stored in the collection okay the event is only
triggered for the last field that was added. I suspect this has
something to do with my WithEvents declaration in cSink but I'm not
sure what to try next.

My code looks like:

*** cField ***
' Declarations
Public Event FieldStatusChange()
' Routines
Sub DoSomething()
...
RaiseEvent FieldStatusChange
End Sub

*** cSink ***
' Declarations
Private WithEvents AllocatedField As cField
Private p_colAllocatedFields As Collection
'Routines
Public Sub AllocateField(objNewField As cField)
Set AllocatedField = objNewField
'Store a pointer to the new field object in our collection
p_colAllocatedFields.Add AllocatedField
End Sub
Private Sub AllocatedField_FieldStatusChange()
msgbox "Event was triggered"
End Sub


If anyone can help it would be greatly appreciated.

Thanks,
Andrew