A
AlexT
Folks
I'm trying to create a generic event handler for textboxes on a form.
The concept would be to consolidate event handling at one place.
To test my idea I have created the following class module
-----------------------------------------------------------------------------------
Option Compare Database
Option Explicit
Public WithEvents xTxtBox As TextBox
Private Sub xTxtBox_Click()
MsgBox "click from " & Me.xTxtBox.name
End Sub
Private Sub xTxtBox_DblClick(Cancel As Integer)
MsgBox "2x click from " & Me.xTxtBox.name
End Sub
-----------------------------------------------------------------------------------
Then, in my form LOAD event I have inserted
-----------------------------------------------------------------------------------
txtCount = 0
' Setup textbox handlers
For Each ctl In Me.lstObj.Controls
If ctl.ControlType = acTextBox Then
txtCount = txtCount + 1
ReDim Preserve txtControls(1 To txtCount)
Set txtControls(txtCount).xTxtBox = ctl
End If
Next ctl
txtControls being defined within the form as
Private txtControls() As New clsControl
-----------------------------------------------------------------------------------
Now this executes fine... but the click / dblClick events are never
raised in my class module...
Any idea / suggestion most welcome
--alexT
I'm trying to create a generic event handler for textboxes on a form.
The concept would be to consolidate event handling at one place.
To test my idea I have created the following class module
-----------------------------------------------------------------------------------
Option Compare Database
Option Explicit
Public WithEvents xTxtBox As TextBox
Private Sub xTxtBox_Click()
MsgBox "click from " & Me.xTxtBox.name
End Sub
Private Sub xTxtBox_DblClick(Cancel As Integer)
MsgBox "2x click from " & Me.xTxtBox.name
End Sub
-----------------------------------------------------------------------------------
Then, in my form LOAD event I have inserted
-----------------------------------------------------------------------------------
txtCount = 0
' Setup textbox handlers
For Each ctl In Me.lstObj.Controls
If ctl.ControlType = acTextBox Then
txtCount = txtCount + 1
ReDim Preserve txtControls(1 To txtCount)
Set txtControls(txtCount).xTxtBox = ctl
End If
Next ctl
txtControls being defined within the form as
Private txtControls() As New clsControl
-----------------------------------------------------------------------------------
Now this executes fine... but the click / dblClick events are never
raised in my class module...
Any idea / suggestion most welcome
--alexT