Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

populate textboxes automatically after combobox is selected

Status
Not open for further replies.

onusonu

MIS
Jun 21, 2005
18
0
0
US
Hi,
I have an order form containing one main combobox(cmbSupplier) and 30 blank comboboxes (cmbitem1...cmbitem30) and 30 amount textboxes (txtamt1..txtamt2...txtamt30). cmbSupplier contains all the suppliers.
When a user select a supplier, only the items that are supplied by the selected supplier will show in the dropdown menu of the 30 blank comboboxes. Sometimes the items are endless and when a users wants to order all items, one has to select each combox box 30 times.

Is there a way where when the supplier is selected, all distinct items supplied by that vendor are automatically populated in the comboboxes. And any items that doesn't have the amount next to it will disappear from the invoice, leaving only the ordered items.

Thank you,

PJ
 
How about a variation? Instead of the 30 comboboxes (which I assume just keeps repeating the same list of items for the selected supplier), use a list box that is populated with the list of items from that suplier. Then with 'multi-select', the user can mark any combination of items. Then they can click a 'Finished' or 'Check Out' button.
Does this help?

Code: Where the vision is often rudely introduced to reality!
 
Thank you! That sounds like a good idea. Once the user select the items from the list box and click "finished," how do you get those item to populate to individual text box so amount can be entered for each item. I have minimal knowledge on VB codes and I don't have a clue. Please help.

PJ
 
In the VBA help have a look at ItemsSelected

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks for the tip. I checked out the vb help and it got me partially there. Here's the code
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(intI + 1)) = ctl.ItemData(varItm)
Next varItm
Next intI
End Sub

The problem with this code is that when I select 5 items, the last items is repeated 5 times in 5 textboxes. How do I get to cycle through each row and place it in the textboxes?

PJ
 
Thanks for the help. I got it. I changed Me("Order" & CStr(intI + 1)) = ctl.ItemData(varItm) to read Me("Order" & CStr(varItm + 1)) = ctl.ItemData(varItm).

PJ
 
Seems that your OrderXX controls are unbound in the Detail section of a continuous form ...

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Now if I don't want to use the list box with "multi-select," how would I populate the items from specific supplier after selecting a supplier in the cmdSupplier combox onto textboxes (txt1, txt3, txt3, etc.)?

PJ
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top