Link to home
Start Free TrialLog in
Avatar of Benyaw
BenyawFlag for Australia

asked on

Default First Row in List Box

how do i make the first record in my list box selected....

i've tried [itemdata] & [selected] but no joy... i urgently need to solve this..

any help appreciated

thanks
benyaw
Avatar of Scott McDaniel (EE MVE )
Scott McDaniel (EE MVE )
Flag of United States of America image

To select the first row:

Me.YourListview.Selected(0) = True
Scott,

That will select the first item, but if you immediately print the value of the list, it will still be null.  I use

Me.lst_Numbers = Me.lst_Numbers.ItemData(-Me.lst_Numbers.ColumnHeads)

you could use 0 as the index # for ItemData, but if you have ColumnHeads turned on, it will not work, so I generally just use this all of the time.
ASKER CERTIFIED SOLUTION
Avatar of Scott McDaniel (EE MVE )
Scott McDaniel (EE MVE )
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Actually, you need two lines, one to set the value and the other to actually select the item in the list:

Me.lst_Numbers = Me.lst_Numbers.ItemData(-Me.lst_Numbers.ColumnHeads)
Me.lst_Numbers.selected(-Me.lst_Numbers.ColumnHeads) = true

Scott,

you are correct, my bad.  Have not had my coffee yet.  I was thinking you had to set the value of the list as well, so I guess the 2nd line would suffice for all circumstances.

Me.lst_Numbers.selected(-Me.lst_Numbers.ColumnHeads) = true