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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combo Boxes, Tables, References

Status
Not open for further replies.

Stainnd

Programmer
Jul 9, 2001
65
US
I have two columns in a table, which we'll call catalog for examples sake. For examples sake, lets also say that the first column is products, and the second column is prices. On my form, I have a combo box, a listbox, and a text box. The combo box contains a list of all products (all of column 1). When the user selects an item from the combo box, first I want the form to add the item to the list box. Then I want it to remove the item from the combo box. Finally, I want the textbox to contain the total amount that the user has selected. In other words, the cumulative sum of the corresponding prices to the products that the user has selected. I can add the item selected to the list box, but I don't know how to remove the selected item from the combo box, and I don't know how to add the price of the item to the text box. Please Help.

-Mike -Mike
 
If you used a wizard to fill your combo and don't know VBA, then you've got to the stage where you need VBA knowledge.

If you know some VBA, then REQUERY the combo to exclude the item passed across to the listbox.

The most efficient way to use a value connected to a COMBO select is to have a column in the COMBO which holds that value - so add another column in the combo to include the value and then refer to it.



"Never argue with an idiot, he'll bring you down to his level - then beat you with experience."
 
Thanks for the help. I like your signature a lot. Anyway, I do know a little VBA...enough to get by. And I used to ahve a rudimentary knowledge of SQL, although I forgot it all. I wasn't quite sure how, or more specifically in what way, you thought I should requery my combo, but I did take your idea of having multiple columns in the combo, and then refering to one. Here's the problem though...when you have more than one column, you set a "BoundColumn", and that is the column whose value is saved in the Combo1.Value property when you select an item from the combo box. However, I want to reference two columns from the combo box, and then put them in different places. I tried to set the BoundColumn to 1, then store that value in one text box, then change the BoundColumn to 2, then store THAT value in the other text box, but I can't figure out how to change the bound column in code. Anyway, hopefully this can help give you a better idea of what my problem is. Thanks
-Mike
 
'create a list box named List0 on the form
Dim lst As ListBox
Dim intI As Integer, intJ As Integer

Set lst = Me!List0
' Print value of each column for each row.
For intI = 0 To lst.ListCount - 1
For intJ = 0 To lst.ColumnCount - 1
Debug.Print lst.Column(intJ, intI)
Debug.Print
Next intJ
Next intI
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top