Solved

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

Posted on 2004-10-08
1
186 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

Independent Software Vendors: 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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…

729 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