Listbox Hightlight / Selected

sznsx

Registered User.
Local time
Today, 18:07
Joined
Jul 25, 2004
Messages
20
I have been looking all around these forms and cant get any answer !

I have a listbox on a form that is part of a record selecting process. When the form first opens, no items in the listbox are highlighted. I need a way to make the first item in the listbox highlighted when the form first opens.

I have come across a few solutions such as: Me.lstCategory.Selected(0) = True

However these solution only VISUALY highlight the selected item. It may be highlighted but you cannot get a value returned from it. I determined this because I have other objects that run queries based on the selected item in the listbox, and they are not computing any values. Only after I phyiscally click on the highlighted item, do other values get computed.


Any ideas? Thanks !
 
Yes

Yes, by clicking on the item in the listbox, the other values are calcuated. I believe that the code only visually highlights the items, therefore I need code that actually selects the item.
 
sz,

If it's always the top item, then you can grab the value doing something similar to this...

Code:
'Get the top item's value.
   Dim MyValue
   MyValue = List0.ItemData(0)

'Test
   Debug.print myvalue

Warning: If your listbox's column heads are enabled, then grab the top item as follows...
Code:
  MyValue = List0.ItemData(1)

Regards,
Tim
 
Ok

Thank you for your post's I will take a look at them and report my findings !!!
 

Users who are viewing this thread

Back
Top Bottom