batteam . . .
Sorry to get back so late. Its hard getting in a decent post at work.
batteam said:
[blue] Can you explain more about the 'Filter as you type' process you mentioned and how it applies to listboxes, if it does.[/blue]
Filter As You Type started out as a way to [blue]search for records[/blue] in comboboxes & listboxes that contain [blue]large recordsets[/blue]. Imagine attempting to scroll thru 50K records to find an entry!
The key to the method involves [blue]updating the criteria of an SQL statement in code used to update the rowsource.[/blue]Typically the text in a textbox is captured via the [blue]OnChange[/blue] event and the SQL is rewritten to the rowsource (this results in an automatic requery for the combobox or listbox). The criteria of the SQL references the data entry textbox. Lets say the search textbox is [blue]txtSearch[/blue]. The code in the OnChange event would look like:
Code:
[blue] Dim SQL As String, DQ As String
DQ = """"
SQL = "SELECT Name " & _
"FROM tblClients " & _
"WHERE [Name] Like " & DQ & Me!txtSearch.Text & "*" & DQ & ";"
Me!LBx1.RowSource = SQL[/blue]
The where clause changes to match Me!txtSearch.Text, setting the filter. Writing the new SQL to the rowsource is the final step (this triggers an auto requery of the listbox).
If the user types abcd the criteria changes per letter as follows:
Code:
[blue]WHERE [Name] Like "a*"
WHERE [Name] Like "ab*"
WHERE [Name] Like "abc*"
WHERE [Name] Like "abcd*"[/blue]
I think you get the Idea.
batteam said:
[blue]. . . is there any way to ensure that the vertical scroll in the list box 'moves' down to the record selected?[/blue]
Not sure about this but I do remember seeing threads on the matter. Try a search!
Realize your filtering here. Even though a combobox automatically selects the first match (typing in the combo textbox), it may still take an additional click of the mouse.
[blue]Your Thoughts? . . .[/blue]
See Ya! . . . . . .