Pass a variable value to multiple text boxes in order

G

Guest

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
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top