Multi column listbox with editable fields

C

Clare

I have a userform which needs to display a list of items which can be
selected via checkboxes, but the users also need to be able to enter 3
quantities for any item they actually select i.e.

Selected Fruit Qty1 Qty2 Qty3
Yes Apple 2 3 1
No Peach 0 0 0
Yes Mango 5 0 3
(where Yes/No is a checkbox)

I have created a listbox on the userform and set the List Style to Option
and MultiSelect to Multi so I get checkboxes but I don’t know how to extend
it to include the extra 3 Quantity columns and relate them to the individual
list items. The users need to be able to type the required quantities if they
select the item, but if the item is not chosen, the Qty columns should
display a zero, or dash or something similar and should be disabled. Is a
listbox the correct way to approach this, or should I be using some other
method?

Ultimately the overall price will then be calculated for each of the items
they have selected and a document is produced (in Word 2003) containing the
appropriate text, images and pricing. I know how to do the document
generation but would really appreciate some assistance with adding the
related quantity boxes to the dialog box.
 
D

Doug Robbins - Word MVP

I believe that what you should have is:

1. A listbox (lstFruit) with four columns
2. The listbox should not be multiselect
3 Three textboxes txtQuantity1, txtQuantity2, txtQuantity3 into which you
will enter the three quantities
4. A command button that has the following code in its click event

With lstFruit
If .ListIndex >= 0 Then
.List(.ListIndex, 1) = txtQuantity1
.List(.ListIndex, 2) = txtQuantity2
.List(.ListIndex, 3) = txtQuantity3
End If
End With

Then if you enter quantities into the three text boxes and select an item in
the list and click on the command button, the quantities that were entered
into the text boxes will be inserted into columns 2 3 and 4 for the select
piece of fruit.


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 

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