Reputation: 902
I want to create a routine that when called will perform the function base on the control names dynamically. Here's my code:
Private Sub myControl(counter as string)
If mySecondControl & counter.Value = "Y" Then
myThirdControl & counter.Caption = "Do Something Here" 'Error syntax
End If
End Sub
Private Sub doThis_Change()
myControl("1")
myControl("2")
End Sub
Upvotes: 0
Views: 42
Reputation: 8508
You need to get the Control
you want from the form's Controls
collection:
If Controls("mySecondControl" & counter).Value = "Y" Then
Controls("myThirdControl" & counter).Caption = "Do Something Here"
End If
Upvotes: 2