Highlight item in a list by code.

  • Thread starter Thread starter Danny
  • Start date Start date
D

Danny

Hi,


I am trying to make a search form where the user enters
the name of what he is searching into a text box. Below
the text box I have a list of all the possible choices.
I wanted to make the list highlight or move down when
ever the user entered a character into the textbox.

Is there any method that list has or a function I can use
to highlight the most smiliar choice.

Thanks
 
-----Original Message-----
Hi,


I am trying to make a search form where the user enters
the name of what he is searching into a text box. Below
the text box I have a list of all the possible choices.
I wanted to make the list highlight or move down when
ever the user entered a character into the textbox.

Is there any method that list has or a function I can use
to highlight the most smiliar choice.

Thanks
.
Hi Danny,
use the listbox.value property

for example:
private sub txtSearch_AfterUpdate()
lstSearch.Value=txtSearch.value
End Sub

However, this will only select an exact match and then
only once the user exits the textbox.

To have a character by character selection is more
interesting. One way is to have the rowsource of the
listbox use the textbox entry as a criterion. Use the
following as an example for the criteria row:

Like forms![frmSearch]![txtSearch].text & "*"

then for the textbox:
Private sub txtSearch_OnChange()
with lstSearch
..requery
..value=.itemdate(0)
end with

this will requery the listbox with each character change
and then select the first list item.

Luck
Jonathan
 
Back
Top