VB6 combo box list items

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • keithsimpson3973
    New Member
    • Aug 2006
    • 63

    VB6 combo box list items

    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

    Code:
    cb = combobox1.listindex
    combobox2.list = combobox1.list
    combobox2.removeitem cb
  • willakawill
    Top Contributor
    • Oct 2006
    • 1646

    #2
    Originally posted by keithsimpson397 3
    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

    Code:
    cb = combobox1.listindex
    combobox2.list = combobox1.list
    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.

    Comment

    • keithsimpson3973
      New Member
      • Aug 2006
      • 63

      #3
      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

      Comment

      • keithsimpson3973
        New Member
        • Aug 2006
        • 63

        #4
        This is what I came up with. The code is executed on the click event of the combo box.


        Code:
        combobox1_click
        Dim uitem as Integer
        uitem = cboSearchField.ListIndex
        cboSearchField2.RemoveItem uitem
        This removes the selection I made in combobox1 from the selection list of the second combo

        Comment

        Working...