dynamic text fields and events

G

Gary Mc

I am trying to create runtime text fields and then capture events on this
text field. I have experimented with several things I have found on the
internet, but have been unsuccessful. The form shows when I run it and the
text box appears, but when I click in it, I do not invoke the control event.
Any ideas?

I have a class module: MyCtrlEvents

******
Option Explicit
Public WithEvents MyBox As MSForms.TextBox

Private Sub MyBox_Click()
MsgBox MyBox.Name & " click!"
End Sub
******

And I have a form with nothing on it. Here is the code.

******
Dim c() As MyCtrlEvents


Private Sub UserForm_Activate()


ReDim c(1)
Set c(0) = New MyCtrlEvents

Set c(0).MyBox = Me.Controls.Add("Forms.Textbox.1")
With c(0).MyBox
.Name = "TextBoxTest"
.Top = 42
.Width = 72
.Height = 18
.Left = 20
End With

End Sub
*****
 
C

Cindy M -WordMVP-

Replied to this question in another group (probably
vba.userforms). There is no click event for a textbox
control...

Cindy Meister
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top