Deon Venter
New Member
- Joined
- Apr 27, 2017
- Messages
- 24
Hi
I've dynamically created a number of textboxes on a userform. Each textbox was added to a class module with some associated attributes. I also have a number of option buttons to the side of the userform. By clicking the textbox, i can update the text in the textbox from the asociated attributes, depending on the currently selected option button.
I would like to update all these textboxes when I click the option button. Something allong the line of for each cntl on userform, trigger the mousedown event in the class module.
Below the code that creates & adds the textbox (with attributes) to a collection.
The class module:
The Class Module works fine when I click on a textbox, but I want to update all textboxes when changing the selected option button.
Thanks in advance
I've dynamically created a number of textboxes on a userform. Each textbox was added to a class module with some associated attributes. I also have a number of option buttons to the side of the userform. By clicking the textbox, i can update the text in the textbox from the asociated attributes, depending on the currently selected option button.
I would like to update all these textboxes when I click the option button. Something allong the line of for each cntl on userform, trigger the mousedown event in the class module.
Below the code that creates & adds the textbox (with attributes) to a collection.
Code:
Set txt = frmMeeting.Controls("frm" & rs!Level_ID & rs!Tunnel_ID).Controls.Add("Forms.textbox.1", "txt" & rs!Level_ID & rs!Tunnel_ID & rs!Ring_ID, True) 'mpgAreas.Pages(Level).Controls.Add("Forms.textbox.1", "txt" & rs!Level_ID & rs!Tunnel_ID & rs!Ring_ID, True)
With txt
.Text = rs!Level_ID & rs!Tunnel_ID & rs!Ring_ID
If rs!Col Mod 2 = 0 Or Level = "824" Then
.Left = 0
Else
.Left = 70
End If
.Width = 70
.Top = txt.Height * CDbl(rs!Row)
.Enabled = True
End With
TotalTXT = TotalTXT + 1
'Add to Rings collection for Class Module
ReDim Preserve LoadPointArray(1 To TotalTXT)
Set LoadPointArray(TotalTXT).txtLoadPoints = txt
LoadPointArray(TotalTXT).LoadPoint = txt.Text
LoadPointArray(TotalTXT).Target = rs!Target
LoadPointArray(TotalTXT).Actuals = rs!Actuals
LoadPointArray(TotalTXT).Remain = rs!Target - rs!Actuals
LoadPointArray(TotalTXT).Compliance = Compliance
LoadPointArray(TotalTXT).Status = rs!Reason
LoadPointArray(TotalTXT).TonsPerDay = DailyTons
The class module:
Code:
Public WithEvents txtLoadPoints As MSForms.TextBox
Public txtLoadPoint, LoadPoint, Status As String
Public Target, Actuals, Remain, TonsPerDay As Integer
Public Compliance As Double
Public Sub txtLoadPoints_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal x As Single, ByVal Y As Single)
If frmMeeting.optStatus.Value = True Then
frmMeeting.Controls("txt" & LoadPoint).Text = Status
End If
If frmMeeting.optTarget.Value = True Then
frmMeeting.Controls("txt" & LoadPoint).Text = Target
End If
The Class Module works fine when I click on a textbox, but I want to update all textboxes when changing the selected option button.
Thanks in advance
Last edited by a moderator: