olorin
Board Regular
- Joined
- Feb 7, 2005
- Messages
- 87
I can populate a userform combobox (cboPnum) using vba and additem method (2 columns)
When the user selects an item in cboPnum, and then enters a qty in a text box (tbQty) the correct information is then added to a listbox (lbItemsShipped).
All great so far...
What I cannot fathom, is how to add another item to the list box.
I obviously have some listbox parameter wrong.
code works fine for one pass, but then it errors out when I try to add another item.
code is
Private Sub tbQty_AfterUpdate()
lbItemsShipped.AddItem cboPnum
lbItemsShipped.List(lbItemsShipped.ListCount - 1, 1) = cboPnum.Column(1)
lbItemsShipped.List(lbItemsShipped.ListCount - 1, 2) = tbQty
lbItemsShipped.SetFocus
cboPnum.RemoveItem (cboPnum.ListIndex)
tbQty = 0
cboPnum = ""
cboPnum.SetFocus
cboDelDate.Enabled = False
tbASN.Enabled = False
lblASN.Enabled = False
lblDelDate.Enabled = False
End Sub
When the user selects an item in cboPnum, and then enters a qty in a text box (tbQty) the correct information is then added to a listbox (lbItemsShipped).
All great so far...
What I cannot fathom, is how to add another item to the list box.
I obviously have some listbox parameter wrong.
code works fine for one pass, but then it errors out when I try to add another item.
code is
Private Sub tbQty_AfterUpdate()
lbItemsShipped.AddItem cboPnum
lbItemsShipped.List(lbItemsShipped.ListCount - 1, 1) = cboPnum.Column(1)
lbItemsShipped.List(lbItemsShipped.ListCount - 1, 2) = tbQty
lbItemsShipped.SetFocus
cboPnum.RemoveItem (cboPnum.ListIndex)
tbQty = 0
cboPnum = ""
cboPnum.SetFocus
cboDelDate.Enabled = False
tbASN.Enabled = False
lblASN.Enabled = False
lblDelDate.Enabled = False
End Sub