Tuesday, March 07, 2006

How to set combobox or listbox to its first item

If the first column is the bound column – then the code would look like this:

Me.Combo1 = Me.Combo1.Column(0, 0)

To set a default value of combobox to its first item you can use similar approach:

Me.Combo1.DefaultValue = Me.Combo1.Column(0, 0)

2 comments:

  1. Bad guess...

    Note that BoundColumn property can differ from Combo to combo.

    The right one is:
    Me.Combo1 = Me.Combo1.ItemData(0)

    ReplyDelete
  2. right, but this is why i mentioned "first column in bound"

    ReplyDelete