By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,593 Members | 2,006 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,593 IT Pros & Developers. It's quick & easy.

VB6 combo box list items

P: 63
I have 6 combo boxes on a vb form. Is there a way, using vb6, to remove the list item that was selected in the first combo box from the list of the second, third fourth, fifth, and sixth combo box list?

This is what I have tried with no luck

Expand|Select|Wrap|Line Numbers
  1. cb = combobox1.listindex
  2. combobox2.list = combobox1.list
  3. combobox2.removeitem cb 
Nov 28 '06 #1
Share this Question
Share on Google+
3 Replies


100+
P: 1,646
I have 6 combo boxes on a vb form. Is there a way, using vb6, to remove the list item that was selected in the first combo box from the list of the second, third fourth, fifth, and sixth combo box list?

This is what I have tried with no luck

Expand|Select|Wrap|Line Numbers
  1. cb = combobox1.listindex
  2. combobox2.list = combobox1.list
  3. combobox2.removeitem cb 
Yes you can do this. You need to have access to the data that is used to poplate the other combo boxes. If it is data from a database you can filter the source to exclude the row you don't want.
Nov 28 '06 #2

P: 63
The combo box lists are not populated from a database. I put the following fields into the combo box list manually at design time as they will never increase or decrease.

The six fields in the Access 2003 db are:

Date_In
Date_Out
Time_In
Time_Out
Unit
Document_Id

So, if user selects Date_In in combobox1 then I want to remove Date_In from the list of combobox 2, combobox3, combobox4, combobox5, and combobox6. Then run the same procedure when I select from combobox2, and continue in the same fashion through all six combobox lists.

If it would be better to populate them from a database and use your procedure, could you point me in the right direction to find out how to do it?

Thanks
Nov 28 '06 #3

P: 63
This is what I came up with. The code is executed on the click event of the combo box.


Expand|Select|Wrap|Line Numbers
  1. combobox1_click
  2. Dim uitem as Integer
  3. uitem = cboSearchField.ListIndex
  4. cboSearchField2.RemoveItem uitem
  5.  
This removes the selection I made in combobox1 from the selection list of the second combo
Nov 28 '06 #4

Post your reply

Sign in to post your reply or Sign up for a free account.