Reputation:
If I want to use a variable within the name of a variable, how would I do that? Im a bit rusty and can't remember or find the correct syntax to do this.
Ex:
For x = 1 To 6
txtBoard [x].Caption = rst(0)
If Not rst(0) = "" Then
boardPresent(x) = True
End If
txtBoardSer [x].Caption = rst(1)
rst.MoveNext
Next
Upvotes: 0
Views: 43
Reputation: 29421
use Controls
collection of your userform object to grab controls by their name
With Me '<--| reference your userform
For x = 1 To 6
.Controls("txtBoard" & x).Caption = rst(0)
If Not rst(0) = "" Then
boardPresent(x) = True
End If
.Controls("txtBoardSer" & x).Caption = rst(1)
rst.MoveNext
Next
End With
Upvotes: 1