I have looked at the other threads on this but haven't come across exactly the same problem. It is driving me nuts. Here is the code that I am using to select fields in a list box and put them into an unbound textbox:
For x = 0 To lstProcName.ListCount - 1
If lstProcName.Selected(x) = True Then
Me.ProcedureNamesCodes = Me.ProcedureNamesCodes & lstProcName.Column(0) & lstProcName.Column(1) & vbCrLf
End If
Next
If I select 2 data items, this will loop thru twice but only put the data of the first item into the textbox twice.
This is logical as I haven't specified which line.
If I use the following code which specifies the items I want, the loop is only processed once, although I select 2 data items. I can't see why:
For x = 0 To lstProcName.ListCount - 1
If lstProcName.Selected(x) = True Then
Me.lstProcName.BoundColumn = 1
Me.ProcedureNamesCodes = Me.ProcedureNamesCodes & Me.lstProcName.ItemData(x) & " "
Me.lstProcName.BoundColumn = 2
Me.ProcedureNamesCodes = Me.ProcedureNamesCodes & Me.lstProcName.ItemData(x) & vbCrLf
End If
Next
Can anyone suggest a reason? Thanks
Geoff.
For x = 0 To lstProcName.ListCount - 1
If lstProcName.Selected(x) = True Then
Me.ProcedureNamesCodes = Me.ProcedureNamesCodes & lstProcName.Column(0) & lstProcName.Column(1) & vbCrLf
End If
Next
If I select 2 data items, this will loop thru twice but only put the data of the first item into the textbox twice.
This is logical as I haven't specified which line.
If I use the following code which specifies the items I want, the loop is only processed once, although I select 2 data items. I can't see why:
For x = 0 To lstProcName.ListCount - 1
If lstProcName.Selected(x) = True Then
Me.lstProcName.BoundColumn = 1
Me.ProcedureNamesCodes = Me.ProcedureNamesCodes & Me.lstProcName.ItemData(x) & " "
Me.lstProcName.BoundColumn = 2
Me.ProcedureNamesCodes = Me.ProcedureNamesCodes & Me.lstProcName.ItemData(x) & vbCrLf
End If
Next
Can anyone suggest a reason? Thanks
Geoff.