Use list box counter to determine which text box to include in a s

S

Steve

I have a multiselect list box populated with a list of tests (test 1, test 2,
test 3, etc)
Next to each line of the list box I have a combobox to determine the timing
of each test. The combo boxes are named cboTime1, cboTime2, etc,
corresponding to the row of the list box to which they are adjacent. The user
selects a test by clicking the list box and then selects a time for each test
selected. I want to then concatenate this info into a text box. I have the
following code:

Private Sub UpdateAddTest_Click()

Dim strFollowTestList As String
Dim strTestList As String
Dim ListBxCount As Integer
Dim ListBxCounter As Integer

For ListBxCounter = 0 To ListBxCount
If [lstOtherTesting].Selected(ListBxCounter) = True Then
strFollowTestList = strFollowTestList [lstOtherTesting].Column(0,
ListBxCounter) & " in " & [cboTime & ListBxCounter]
lstOtherTesting.Selected(ListBxCounter) = False
End If
Next ListBxCounter

strTestList = "At that visit I have requested that the following testing
be performd: " & strFollowTestList & "."
End Sub

I want procedure to determine which cboTime (i.e. cboTime1 or cboTime2 ect)
to use based on the list box row number selected but it doesn't recognize my
reference to the cboTime control when I code it as '[cboTime &
ListBxCounter]'. Any suggestions on how to do this? Thanks.
 
M

Marshall Barton

Steve said:
I have a multiselect list box populated with a list of tests (test 1, test 2,
test 3, etc)
Next to each line of the list box I have a combobox to determine the timing
of each test. The combo boxes are named cboTime1, cboTime2, etc,
corresponding to the row of the list box to which they are adjacent. The user
selects a test by clicking the list box and then selects a time for each test
selected. I want to then concatenate this info into a text box. I have the
following code:

Private Sub UpdateAddTest_Click()

Dim strFollowTestList As String
Dim strTestList As String
Dim ListBxCount As Integer
Dim ListBxCounter As Integer

For ListBxCounter = 0 To ListBxCount
If [lstOtherTesting].Selected(ListBxCounter) = True Then
strFollowTestList = strFollowTestList [lstOtherTesting].Column(0,
ListBxCounter) & " in " & [cboTime & ListBxCounter]
lstOtherTesting.Selected(ListBxCounter) = False
End If
Next ListBxCounter

strTestList = "At that visit I have requested that the following testing
be performd: " & strFollowTestList & "."
End Sub

I want procedure to determine which cboTime (i.e. cboTime1 or cboTime2 ect)
to use based on the list box row number selected but it doesn't recognize my
reference to the cboTime control when I code it as '[cboTime &
ListBxCounter]'.


The syntax for that kind of reference is:
. . . & Me("cboTime" & ListBxCounter)

But I think the rest of the code you posted has other
problems. Maybe you typed it into your post and made some
typos? If that's true, you should use Copy/Paste so we
don't waste time trying to debug your typing skills instead
your real code.
 

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