ListIndex for a cbo box

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?
 
D

Douglas J. Steele

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)
 
D

Douglas J. Steele

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top