Requery the list box RecordSource Query with each keystroke.

G

Guest

I have a form with an unbound textbox and a listbox. I want to requery the
listbox object with each keystroke in the textbox. The listbox's record
source is a query that has a criteria in the ClientName Field of -- Like
ReturnValue(). ReturnValue() should return what is currently showing in the
textbox surrounded with "*". I am trying to capture what is being typed in
the textbox with the KeyDown Event of the textbox and using KeyCodes to build
a string. For Example if I open the form and enter the textbox and type the
letter "a" then KeyDown will start making a Variable of *a* (using KeyCode
testsing) and the listbox will requery showing all clients with an "a" in the
Name. And then if I type a "t' then in the KeyDown Event the Variable will
be *at* and requery the listbox to show all Names Like *at* etc. Building
this Variable is very cumbersome but I cannot get the Value of the textbox
because it does not have a value until updated. Is there a faster. easier
more straight forward way to return what is being typed in the textbox? I
want the incremental search on the LIKE criteria to occcur with each key
stroke. I guess the bottom line question is how do you return the string
showing in a textbox with each keystroke ie before the textbox is updated?

I hope this is clear.
Thanks for your help.
 
M

Marshall Barton

Steven said:
I have a form with an unbound textbox and a listbox. I want to requery the
listbox object with each keystroke in the textbox. The listbox's record
source is a query that has a criteria in the ClientName Field of -- Like
ReturnValue(). ReturnValue() should return what is currently showing in the
textbox surrounded with "*". I am trying to capture what is being typed in
the textbox with the KeyDown Event of the textbox and using KeyCodes to build
a string. For Example if I open the form and enter the textbox and type the
letter "a" then KeyDown will start making a Variable of *a* (using KeyCode
testsing) and the listbox will requery showing all clients with an "a" in the
Name. And then if I type a "t' then in the KeyDown Event the Variable will
be *at* and requery the listbox to show all Names Like *at* etc. Building
this Variable is very cumbersome but I cannot get the Value of the textbox
because it does not have a value until updated. Is there a faster. easier
more straight forward way to return what is being typed in the textbox? I
want the incremental search on the LIKE criteria to occcur with each key
stroke. I guess the bottom line question is how do you return the string
showing in a textbox with each keystroke ie before the textbox is updated?


Use the text box's Change event to retrieve its Text
property:

strCriteria = "*" & Me.textbox.Text & "*"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top