Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!

possible to sink a control event from a separate class?

Discussion in 'Information Technology' started by rpardee@gmail.com, Jul 28, 2006.

  1. rpardee@gmail.com

    rpardee@gmail.com
    Expand Collapse
    Guest

    Hey All,

    I want to handle a combobox AfterUpdate event from a separate class
    module. The below doesn't seem to work, *unless* I also create a
    separate AfterUpdate handler right in the form module. I don't want to
    have to do that. Is there something else I can do?

    ' -------------------------------------------
    ' Here is the entire class module:

    Private WithEvents cmb As ComboBox

    Property Set c(x As ComboBox)
    Set cmb = x
    End Property

    Private Sub cmb_AfterUpdate()
    MsgBox "In after-update!"
    End Sub

    ' -------------------------------------------
    ' In the form I do this:

    Private m As Class1

    Private Sub Form_Load()
    Set m = New Class1
    Set m.c = Me.Combo0
    End Sub
    ' -------------------------------------------

    It feels like the form doesn't create the combobox 'withevents' unless
    there's a handler right in the form module. Is that what's going on?
    If so, is there a way around it?

    Thanks!

    -Roy
     
  2. Loading...

    Similar Threads Forum Date
    Movies Ashdoc's movie review---Mission impossible 5 Rogue nation Theatre, Movies & Cinema Aug 12, 2015
    India Professor Bhullar's release possible after landmark SC judgement Breaking News Jan 21, 2014
    USA UPDATED! Dr. Prabjot Singh, Sikh Professor Attacked in Possible Hate Crime (2 Videos) Breaking News Sep 23, 2013
    A Shabad I came across - possible interpretations Sikh Sikhi Sikhism Aug 28, 2013
    To know God is to Love him, why this is not possible Sikh Sikhi Sikhism Mar 31, 2012

  3. roy

    roy
    Expand Collapse
    Guest

    For the record--this is possible. Here is a class that works:

    ' -------------------------------------------
    ' Here is the entire class module:

    Private WithEvents cmb As ComboBox

    Property Set c(x As ComboBox)
    Set cmb = x
    ' This is the magic line of code:
    cmb.AfterUpdate = "[Event Procedure]"
    End Property

    Private Sub cmb_AfterUpdate()
    MsgBox "In after-update!"
    End Sub

    ' -------------------------------------------

    Cheers,

    -Roy
     

Share This Page