Combobox reset

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dbspang
    New Member
    • Jul 2007
    • 1

    Combobox reset

    I am using VBA and trying to find the right language to reset a combo box so it is blank.

    After the user selects an item in the combobox, there is a button that adds that item to a form. The problem is that the last item selected still appears in the combobox window. It needs to be blank so that the NotInList code works. I already have a set of null values in the combobox.

    Thanks for any help
  • kadghar
    Recognized Expert Top Contributor
    • Apr 2007
    • 1302

    #2
    Originally posted by dbspang
    I am using VBA and trying to find the right language to reset a combo box so it is blank.

    After the user selects an item in the combobox, there is a button that adds that item to a form. The problem is that the last item selected still appears in the combobox window. It needs to be blank so that the NotInList code works. I already have a set of null values in the combobox.

    Thanks for any help
    try with

    ComboBox1.Remov eItem (ComboBox1.List Index)

    this will remove the selected item from the combo box.

    Hope that helps.

    Comment

    • pureenhanoi
      New Member
      • Mar 2007
      • 175

      #3
      Originally posted by kadghar
      try with

      ComboBox1.Remov eItem (ComboBox1.List Index)

      this will remove the selected item from the combo box.

      Hope that helps.
      one more addition:
      ComboBox1.Clear -> clear all items from combobox

      Comment

      • manoj bhatt
        New Member
        • Jul 2007
        • 3

        #4
        Originally posted by dbspang
        I am using VBA and trying to find the right language to reset a combo box so it is blank.

        After the user selects an item in the combobox, there is a button that adds that item to a form. The problem is that the last item selected still appears in the combobox window. It needs to be blank so that the NotInList code works. I already have a set of null values in the combobox.

        Thanks for any help
        Got a solution, or not? Specify whether u have to remove the chosen item from the combo or clear all the contents from the combo or just put combo unselected ( a situation when not a item selected in combo).

        I'll give u a solution.

        Comment

        • Robbie
          New Member
          • Mar 2007
          • 180

          #5
          Originally posted by dbspang
          The problem is that the last item selected still appears in the combobox window. It needs to be blank ...
          I think this is what you mean...

          If you want the combobox to have no item selected, set its ListIndex value to -1.
          That way it will go back to looking 'blank', as it will be when the program first runs unless you set its ListIndex value in a Form_Load event or some other event.

          This works in VB6. I don't have any another verison to try it on, sorry.

          Comment

          • rhytoverm
            New Member
            • Feb 2010
            • 1

            #6
            re:

            if you want the list to be as same as it was,, but just give a blank to it
            here is the simple way to do so.

            private sub button_reset()

            combobox.ListIn dex = -1

            endsub

            Comment

            Working...