The code below allows me to select multiple values from list box and automatically populate the selected values to textboxes. The problem is that if I select, say, item1, item2, and item 5, those items will populate txtbox1, txtbox2, and txtbox5, leaving txtbox3,4 empty.
How do I get it to populate the next empty textbox continuously?
Private Sub cmdOrder_Click()
Dim frm As Form, ctl As Control
Dim varItm As Variant
Dim intI As Integer
Set frm = Forms!PurchaseOrderForm
Set ctl = frm!lstItems
For intI = 0 To ctl.ItemsSelected.count - 1
For Each varItm In ctl.ItemsSelected
Me("Order" & CStr(varItm + 1)) = ctl.ItemData(varItm)
Next varItm
Next intI
End Sub
pj
How do I get it to populate the next empty textbox continuously?
Private Sub cmdOrder_Click()
Dim frm As Form, ctl As Control
Dim varItm As Variant
Dim intI As Integer
Set frm = Forms!PurchaseOrderForm
Set ctl = frm!lstItems
For intI = 0 To ctl.ItemsSelected.count - 1
For Each varItm In ctl.ItemsSelected
Me("Order" & CStr(varItm + 1)) = ctl.ItemData(varItm)
Next varItm
Next intI
End Sub
pj