Hi all -
I've created a number of dynamic textboxes on a form, and created the "_change" function within a separate class so I can have one common function to handle them all (UpdateTotals). Despite me trying everything, I cannot access the .tag property of the textbox. I can see it in the Watch window, but .tag property isn't even in the drop down list. This is weird.
Here's where I set up the dynamic textboxes:
cmdArray is declared globally as:
And Class1 is:
The error is a Type Mismatch on the above UpdateTotals call (the sub is expecting a string, so should be good). As I say, if I step through and put a watch on CmdEvents.Tag, its there and is correct. I've even tried explicity casting it using CStr, but no joy.
If I begin typing "CmdEvents." in the editor, TAG doesn't come up on the drop down box., despite it being an MSForm.TextBox type. As an aside, I cannot access the .name property either.
Can anyone shed any light?
Many thanks,
MrP.
I've created a number of dynamic textboxes on a form, and created the "_change" function within a separate class so I can have one common function to handle them all (UpdateTotals). Despite me trying everything, I cannot access the .tag property of the textbox. I can see it in the Watch window, but .tag property isn't even in the drop down list. This is weird.
Here's where I set up the dynamic textboxes:
VBA Code:
Dim MarksLabel As Control
GlobalMarkCount = GlobalMarkCount + 1
Set MarksLabel = Frame1.Controls.Add("forms.textbox.1")
With MarksLabel
.Text = Mark
.Width = 42
.Height = 24
.Font.Name = "Calibri"
.Font.Size = 14
.Name = "MarksLabel_" & PupilLocation & "_" & QuestionLocation
.Left = MarkLeftMargin + QuestionLocation * (.Width + 1)
.top = TopBorder + 3 + (PupilLocation - 1) * 25
.Tag = "M" & PupilLocation & " " & QuestionLocation
.TabIndex = GlobalMarkCount
End With
ReDim Preserve cmdArray(1 To GlobalMarkCount)
Set cmdArray(GlobalMarkCount).CmdEvents = MarksLabel
Set MarksLabel = Nothing
cmdArray is declared globally as:
VBA Code:
Dim cmdArray() As New Class1
And Class1 is:
VBA Code:
Option Explicit
Public WithEvents CmdEvents As MSForms.TextBox
Private Sub CmdEvents_Change()
AssessmentMarkForm.UpdateTotals (CmdEvents.Tag)
End Sub
The error is a Type Mismatch on the above UpdateTotals call (the sub is expecting a string, so should be good). As I say, if I step through and put a watch on CmdEvents.Tag, its there and is correct. I've even tried explicity casting it using CStr, but no joy.
If I begin typing "CmdEvents." in the editor, TAG doesn't come up on the drop down box., despite it being an MSForm.TextBox type. As an aside, I cannot access the .name property either.
Can anyone shed any light?
Many thanks,
MrP.