combo box - select 1st item

combo box - select 1st item

Post by dave » Sun, 17 Apr 2005 22:12:39


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.
 
 
 

combo box - select 1st item

Post by dave » Sun, 17 Apr 2005 22:59:37

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.



1st

 
 
 

combo box - select 1st item

Post by Marshall B » Mon, 18 Apr 2005 01:02:45

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]
 
 
 

combo box - select 1st item

Post by dave » Mon, 18 Apr 2005 04:53:43

Thanks Marshall, I didn't know about the ItemData() technique - it's great
to get these kinds of tips. Thanks again, Dave H.




is
row
first.
the
be a