ClimoC
Well-known Member
- Joined
- Aug 21, 2009
- Messages
- 584
Howdy gang
Trying to do a shortcut - Userform is having dynamic number of items created at runtime for the user to interact with.
I've done this successfully with Checkboxes, and that's all fine - but I was as I'm adding a lot of textboxes and comboboxes, and they all need an event fired on _Change(), I thought I'd be able to create a Custom Class of type 'MSForms.Control', and then from a Case statement fire the right event (using the convention-named Name of the control for its type) - but I'm hitting walls.
The following bugs as "Error 459 - Object or Class does not support the set of events" - which I suppose makes sense, on the indicated line below:
And in the Userform itself:
So, is there any way of tweaking this to place a path for all _Change() events to go (as Textboxes and Comboboxes both have _Change Events) - or am I barking up the wrong tree because a generic 'Control' doesn't have an Event for that?
Am I better off just making 2 classes - one for the Textboxes and one for the Comboboxes?
Thanks
Trying to do a shortcut - Userform is having dynamic number of items created at runtime for the user to interact with.
I've done this successfully with Checkboxes, and that's all fine - but I was as I'm adding a lot of textboxes and comboboxes, and they all need an event fired on _Change(), I thought I'd be able to create a Custom Class of type 'MSForms.Control', and then from a Case statement fire the right event (using the convention-named Name of the control for its type) - but I'm hitting walls.
The following bugs as "Error 459 - Object or Class does not support the set of events" - which I suppose makes sense, on the indicated line below:
Code:
'Class Module code (class name is 'clsSportFixEdit'):
Public WithEvents EditCntrl As MSForms.control
Public gID As Long
Private Sub EditCntrl_Change()
If Not Application.EnableEvents = False Then
With VersionDetailForm
Select Case True
Case EditCntrl.Name Like "*Sport*"
'Call Something
Case EditCntrl.Name Like "*VerNum*"
Call CheckVers
Case Else
End Select
End With
End If
End Sub
And in the Userform itself:
Code:
Private mVDFElementEvents(1 To (Ver_Fix_Num * 10)) As clsSportFixEdit
'and a function is called from Initialize()
Function MakeSportsEditFixtures(ByVal idx As Long)
Dim myTop As Long, elemID As Long, elemCnt As Long
myTop = (idx - 1) * 78
elemID = (idx - 1) * 10
'Increment, but start at 0
elemCnt = 0
'Main Controls
With Me.Frame1
elemCnt = elemCnt + 1
Set mVDFElementEvents(elemID + elemCnt) = New clsSportFixEdit
'//BUGS ON THIS LINE
Set mVDFElementEvents(elemID + elemCnt).EditCntrl = .Controls.Add("Forms.Textbox.1", "V" & idx & "Event", True)
'//
With mVDFElementEvents(elemID + elemCnt).EditCntrl
.Top = myTop + 18
.Height = 18
.Width = 126
.Left = 48
End With
elemCnt = elemCnt + 1
Set mVDFElementEvents(elemID + elemCnt) = New clsSportFixEdit
Set mVDFElementEvents(elemID + elemCnt).EditCntrl = .Controls.Add("Forms.Combobox.1", "V" & idx & "Type", True)
With mVDFElementEvents(elemID + elemCnt).EditCntrl
.Top = myTop + 18
.Height = 18
.Width = 90
.Left = 180
End With
End with
So, is there any way of tweaking this to place a path for all _Change() events to go (as Textboxes and Comboboxes both have _Change Events) - or am I barking up the wrong tree because a generic 'Control' doesn't have an Event for that?
Am I better off just making 2 classes - one for the Textboxes and one for the Comboboxes?
Thanks