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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

enhanced search 1

Status
Not open for further replies.

Moxy1

Programmer
Aug 29, 2002
75
US
i have a list box with 100's of rows. I'd like to create an unbound field that as a user types it will begin to filter down the list. Has anybody attempted this and would you be able to point me to some examples?

Here is basically what i've tried:

Code:
Private Sub txtSearch_Change()

Dim strSearch As String
Dim strValue As String

strValue = Me.txtSearch

strSearch = "SELECT DISTINCT tblObject.obj_location FROM tblObject WHERE (((tblObject.ojb_type)=Forms!frmMainObject!txtType)) AND ((tblObject.ojb_location) Like '" & strValue & "*'; "

Me.lstBox.RowSource = strSearch

End Sub

The problem that i run in to is that when the search field is changed the new value is not being picked up.

 
Replace this:
strValue = Me.txtSearch
with this:
strValue = Me!txtSearch.Text

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
G'day,

And add line as below to requery the list....

Code:
...

Me.lstBox.RowSource = strSearch
[red]me!lstbox.requery[/red]

Maybe consider the Afterupdate event, (or even an invisible button with Default set to true) rather than on change so that the code only runs once the user has typed something and hit enter rather than on every keypress?

Good luck!

JB
 
JB, the Requery is automatically triggered when the RowSource is changed.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks PHV! I didn't know that, is it true of every version of Access? I'm sure I used to need it and these habits stick. But then, so does sh!t......!

Cheers for the heads up mate, will remove my redundant lines on Monday.

JB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top