moa
03-01-2007, 09:31 AM
Hi,
I have some classes for controls. My combobox class has an afterUpdate event that doesn't run. Change event works fine but AfterUpdate is just ignored. some of the comboboxes already have afterupdate events (was going to exclude them from the class) would this be the reason why none of the AfterUpdate events fire or is it just not recognized as an event? Doesn't make sense to me.
Class Module:
Option Explicit
Public WithEvents cbCtrls As msforms.ComboBox
Private cmbName As String
Private essential As Boolean
Property Let isEssential(yesNo As Boolean)
essential = yesNo
End Property
Property Get isEssential() As Boolean
isEssential = essential
End Property
Property Let Name(str As String)
cmbName = str
End Property
Property Get Name() As String
Name = cmbName
End Property
Private Sub cbCtrls_AfterUpdate()
MsgBox "Work dammit!"
End Sub
Public Sub Delete()
cbCtrls.Text = ""
End Sub
Initialising:
Public Sub comboBoxClass_Initialise()
Dim ctrl As Control
Dim X As Long
Dim thisCtrl As String
comboCount = 0
For Each ctrl In UserForm1.specFrame.Controls
If TypeName(ctrl) = "ComboBox" Then
thisCtrl = ctrl.Name
comboCount = comboCount + 1
ReDim Preserve combo_box(1 To comboCount)
With combo_box(comboCount)
Set .cbCtrls = ctrl
.Name = thisCtrl
Select Case (thisCtrl)
Case "cmbTSize"
.isEssential = True
Case "cmbPaperType"
.isEssential = True
Case "cmbType"
.isEssential = True
Case Else
.isEssential = False
End Select
End With
End If
Next
End Sub
I have some classes for controls. My combobox class has an afterUpdate event that doesn't run. Change event works fine but AfterUpdate is just ignored. some of the comboboxes already have afterupdate events (was going to exclude them from the class) would this be the reason why none of the AfterUpdate events fire or is it just not recognized as an event? Doesn't make sense to me.
Class Module:
Option Explicit
Public WithEvents cbCtrls As msforms.ComboBox
Private cmbName As String
Private essential As Boolean
Property Let isEssential(yesNo As Boolean)
essential = yesNo
End Property
Property Get isEssential() As Boolean
isEssential = essential
End Property
Property Let Name(str As String)
cmbName = str
End Property
Property Get Name() As String
Name = cmbName
End Property
Private Sub cbCtrls_AfterUpdate()
MsgBox "Work dammit!"
End Sub
Public Sub Delete()
cbCtrls.Text = ""
End Sub
Initialising:
Public Sub comboBoxClass_Initialise()
Dim ctrl As Control
Dim X As Long
Dim thisCtrl As String
comboCount = 0
For Each ctrl In UserForm1.specFrame.Controls
If TypeName(ctrl) = "ComboBox" Then
thisCtrl = ctrl.Name
comboCount = comboCount + 1
ReDim Preserve combo_box(1 To comboCount)
With combo_box(comboCount)
Set .cbCtrls = ctrl
.Name = thisCtrl
Select Case (thisCtrl)
Case "cmbTSize"
.isEssential = True
Case "cmbPaperType"
.isEssential = True
Case "cmbType"
.isEssential = True
Case Else
.isEssential = False
End Select
End With
End If
Next
End Sub