focus in listboxes

M

marco

Is it possible to set the focus to a particular record in
a list box? (so not to the box itself, but to an 'item' in
the box)

Thanks,


Marco van Haaften
 
B

Bruce M. Thompson

Is it possible to set the focus to a particular record in
a list box? (so not to the box itself, but to an 'item' in
the box)

Sure, but that means actually setting the value of the listbox as in the
following examples (this assumes that the listbox's "Multiselect" property is
set to "None"):

If the bound column in the listbox is a number ...

Me.MyListBox.Value = 22

Or, if the bound column in the listbox is a string ...

Me.MyListBox.Value = "A35M7"

And, if you simply want to set the value to the first item in the list,
regardless of the value, you can use (automatically accommodates the listbox's
"ColumnHeads" property setting):

Me.MyListBox.Value = Me.MyListBox.ItemData(Abs(Me.MyListBox.ColumnHeads))
 

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