ListIndex for a cbo box

  • Thread starter Thread starter tryit
  • Start date Start date
T

tryit

In the click event of a button I have the following line:

Me.cboCBB.ListIndex = 0

When I click the button I'm told this is an improper use of
ListIndex. What am I doing wrong?
 
The ListIndex property is read-only.

If you're trying to select the first element in the combo box, try

Me.cboCBB = Me.cboCBB.ItemData(0)
 
To be more generic, you could use

Me.cboCBB = Me.cboCBB.ItemData(Abs(Me.cboCBB.ColumnHeads))


--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


The ListIndex property is read-only.

If you're trying to select the first element in the combo box, try

Me.cboCBB = Me.cboCBB.ItemData(0)

Thank you, Doug. That worked.

I got confused because Microsoft's help on this suggested you could
set the index using listindex:

http://office.microsoft.com/en-us/access/HA012327561033.aspx (see
last example)

Incidentally, because I had column heads turned on, I needed index 1.
Index 0 gave me an error.


Tom
 
Back
Top