lamha
09-10-2000, 04:13 AM
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.
Thanks for any help in advance.
|
View Full Version : highlight the first item in list box by default lamha 09-10-2000, 04:13 AM 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. accesswatch 09-10-2000, 12:14 PM 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 (http://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).] lamha 09-11-2000, 06:15 AM 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. SONER SULEYMAN 03-19-2007, 08:33 AM 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 IR_Moon 03-28-2007, 02:30 PM For some off reason, mine worked (and succesfully selected the first item in the list box) when I changed the code to: 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! |