Pass a variable value to multiple text boxes in order

M

Mark Senibaldi

Hi,

I have an unbound form that is using an array 1-cbo_Holes. I have a dlookup
that looks up a value from a table for each hole. I have 18 text boxes
(Named Par1, Par2, Par3... Par 18). I am able to get the array to find the
value for each hole from the table but do not know how to pass this value to
the text boxes in order (Par1-first, Par2-second, etc...) Below is my code.

Private Sub Command87_Click()
Dim i As Variant, holepar As Integer, HoleID As String

'Load up All the Arrays
For i = 1 To Me.cbo_holes
HoleID = Me.cbo_course & "-" & Me.cbo_tees & "-" & i
Me.txt_holeid = HoleID
MsgBox HoleID
holepar = DLookup("[Par]", "[tbl_Course_Info_Holes]", "[HoleID] = " _
& "forms!frm_round_new.txt_holeid")
MsgBox holepar
holenumber = "par" & i
MsgBox holenumber
Next i
End sub
 
M

Marshall Barton

Mark said:
I have an unbound form that is using an array 1-cbo_Holes. I have a dlookup
that looks up a value from a table for each hole. I have 18 text boxes
(Named Par1, Par2, Par3... Par 18). I am able to get the array to find the
value for each hole from the table but do not know how to pass this value to
the text boxes in order (Par1-first, Par2-second, etc...) Below is my code.

Private Sub Command87_Click()
Dim i As Variant, holepar As Integer, HoleID As String

'Load up All the Arrays
For i = 1 To Me.cbo_holes
HoleID = Me.cbo_course & "-" & Me.cbo_tees & "-" & i
Me.txt_holeid = HoleID
MsgBox HoleID
holepar = DLookup("[Par]", "[tbl_Course_Info_Holes]", "[HoleID] = " _
& "forms!frm_round_new.txt_holeid")
MsgBox holepar
holenumber = "par" & i
MsgBox holenumber
Next i
End sub


I think you're looking for:

Me.Controls("par" & i) = something
 
M

Mark Senibaldi

Worked like a charm. Thanks a lot.
--
MSS


Marshall Barton said:
Mark said:
I have an unbound form that is using an array 1-cbo_Holes. I have a dlookup
that looks up a value from a table for each hole. I have 18 text boxes
(Named Par1, Par2, Par3... Par 18). I am able to get the array to find the
value for each hole from the table but do not know how to pass this value to
the text boxes in order (Par1-first, Par2-second, etc...) Below is my code.

Private Sub Command87_Click()
Dim i As Variant, holepar As Integer, HoleID As String

'Load up All the Arrays
For i = 1 To Me.cbo_holes
HoleID = Me.cbo_course & "-" & Me.cbo_tees & "-" & i
Me.txt_holeid = HoleID
MsgBox HoleID
holepar = DLookup("[Par]", "[tbl_Course_Info_Holes]", "[HoleID] = " _
& "forms!frm_round_new.txt_holeid")
MsgBox holepar
holenumber = "par" & i
MsgBox holenumber
Next i
End sub


I think you're looking for:

Me.Controls("par" & i) = something
 
Top