Solved

How to pass a reference of a member of a control array?

Posted on 2004-10-08
1
185 Views
Last Modified: 2010-05-02
Hi Experts:

I need to modify the behavior of a combobox and am using a class module as the helper class.  It works fine passing in a single control, but I need to modify it to accept mambers of a control array.

In my form code I have this:

Private oCombo As cComboHelperArray

Private Sub cbArray_GotFocus(Index As Integer)
    'Attach the helper class to ComboBox array cbArray in the GotFocus event
    oCombo.AttachTo cbArray, Index
End Sub

And in the Class Module:

Private WithEvents moCombo As ComboBox

Public Sub AttachTo(oCombo As Variant, ByVal Index As Long)
   
    Dim c As Control
    'On Error Resume Next
    For Each c In oCombo
        If (c.Index = Index) And (TypeOf c Is ComboBox) Then
            Set moCombo = c '<< Error here 459: Object or Class does not Support the set of events
            Exit For
        End If
    Next
    m_Index = c.Index 'Save the index of the currently attached control
    Debug.Print "Attached " & oCombo.Name
 
End Sub

See the error 459 noted above.  Any ideas how I can set the helper combobox to get the events of the attached combobox array?

Thanks in advance...
0
Comment
Question by:nichia
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 250 total points
ID: 12262665
You can't use the WithEvents keyword to reference a control array in any way.

To trap events from inside your class module you will have to break out your control into individual controls.

Sorry,

~IM
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question