Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Narrowing records as you type each letter in 1

Status
Not open for further replies.

Ktx7ca

IS-IT--Management
Apr 5, 2008
88
CA
Hello Everyone

The issue I'm having is that I need the listbox to narrow the displayed records as I type the letters in the Textbox

I can't quite figure out what event in the textbox to put the listbox requery statement into to get it to work right

Any Ideas on this would be greatly aprecaited

chris

 
Use a CLASS module, not a standard one.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
that is a MASSIVE amount of code for what should be a really simple thing. i use the ChangeEvent on a textbox to filter a query-based listbox all the time. here is the code i use:

On Change of textbox that i'm typing in my text (txtSearchText)
Code:
Private Sub txtSearchText_Change()
    
    Dim vStrSearch As String
    
    vStrSearch = txtSearchText.Text
    txtSearchVal.Value = vStrSearch
    
    Me.lstItems.Requery
End Sub

txtSearchVal is a hidden textbox on the same form.

i then have this parameter in the query (for the chosen field that needs filtering) that is feeding the listbox:

Code:
Like "*" & [forms]![frmItems].[txtSearchVal] & "*"
 
Although there may be a lot of code it is transparent to the user because it is fully encapsulated in a class module. The user only has to write two lines of code and instantiate one class object for any listbox. That is it.
Code:
Public faytList As FindAsYouTypeListBox
Private Sub Form_Load()
  Set faytList = New FindAsYouTypeListBox
  faytList.Initialize Me.lstProducts, Me.txtBxFilter, "ProductName"
End Sub
No need to build a query and no need for a hidden text box. Do not even have to write an event procedure except
the form load event. Also the class automatically handles a change event, after update event, and the forms on current event.

The code was originally written for a combobox, which has more functionality. More important this demonstrates the concept of extending the functionality of access objects by capturing their events in a user defined class and building additional functionality. This is probably over your head, but definitely worth learning if you are doing any real Access development. This will change the way you build applications. More flexible, more reusable, and more functional.

 
HI MajP

I'm using your code and I can't seem to select any of the records that are displayed.

any Ideas?
 
Opps Sorry MajP My fault I acdentally removed one letter from the control source some how.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top