For each cntl trigger class module

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.

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:

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.

Forum statistics

Threads
1,223,630
Messages
6,173,453
Members
452,514
Latest member
cjkelly15

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top