combo box - select 1st item

  • Thread starter Thread starter dave h
  • Start date Start date
D

dave h

Hi,

After setting the rowsource in VBA for a combo box, I need to select the 1st
item for display in the text box part of the combo box.
Neither "Selected(0)" or "listindex = 0" work for this purpose. Must be a
simple answer, but I can't find a similar question on this board.

Thanks, Dave H.
 
The VBA documentation for the combo box ListIndex property says that this is
a "read only" property - this is not true as it can be used to select a row
in the combo box. My mistake was not setting focus on the combo box first.
 
Way to go Dave, fighting your way through documentation
omissions to discover that trick is a significant
achievement.

Here's another way to do what you want without the need to
change the focus:
Me.Combo = Me.Combo.ItemData(0)
 
Thanks Marshall, I didn't know about the ItemData() technique - it's great
to get these kinds of tips. Thanks again, Dave H.

Marshall Barton said:
Way to go Dave, fighting your way through documentation
omissions to discover that trick is a significant
achievement.

Here's another way to do what you want without the need to
change the focus:
Me.Combo = Me.Combo.ItemData(0)
--
Marsh
MVP [MS Access]


dave said:
The VBA documentation for the combo box ListIndex property says that this is
a "read only" property - this is not true as it can be used to select a row
in the combo box. My mistake was not setting focus on the combo box first.

"dave h" wrote the
1st
 
Back
Top