highlight the first item in list box by default

lamha

Registered User.
Local time
Today, 23:02
Joined
Jun 21, 2000
Messages
76
I have a three-column list box that displays the search results. Is there a way to highlight the first row in list box by default?
Thanks for any help in advance.
 
If you want to select the first row of a Listbox irespective of the value of the first row you can use:

lstMyListBox.Selected(0) = True


If you want to select a specific row based on a LISTBOX or COMBO BOX 'value' then the following will work:

This will work if you know the value of the first record:
Using Combo box 'cboIdStatus'
First row value of '0'
Placed in Forms ONLOAD event

Private Sub Form_Load()
Dim Myint As Integer
Myint = 0
Me.cboIdStaus = Myint

'if required additional code to query or run code based on the selection

End Sub

You can adopt to run from any event you want, you can also adopt it to select any other known listbox or combobox value. The above is useful for selecting a value when a form is loaded

Hope this helps
Trevor from www.accesswatch.co.uk

[This message has been edited by accesswatch (edited 09-10-2000).]

[This message has been edited by accesswatch (edited 09-10-2000).]
 
Thanks, it worked except there's a minor problem: If the first row is not the item I want,I cannot select another row.
Please help.
 
Highligting first row in list box by default

Hi
I have used the code below for highligting the list box by default and has not worked for me.

lstReference.Selected(0) = True

Can anyone help?
thank you

SONER
 
For some off reason, mine worked (and succesfully selected the first item in the list box) when I changed the code to:

Code:
lstReference.Selected(1) = True

Not sure why or how or whatever... but the 0 wasn't working for me... or it was selecting some random record in big lists. Anyhoo... try it... might work for you as well as it did for me.

Cheers!
 

Users who are viewing this thread

Back
Top Bottom