Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Matilda Hughes   on Oct 29 In MS Office Category.

  
Question Answered By: Adalwolfa Fischer   on Oct 29

What I'm suggesting it to create a function in a module:

Function Search_String(ByVal FieldName, ByVal FieldVal)

Then, for each of the textboxes, create a change event.
oops.. just realized (and tested) the change event would execute for each
letter typed.
You should use either an Update event, or an Exit event.
The difference is: the Exit event would execute whenever you select
something OUTSIDE of the textbox. The Update event would execute after you
exit but only if you changed something in the textbox.

In the Exit or Update event, test to see if the textbox  has a value
(in case  they CLEARED the textbox)
like:
if (len(txtLastName.Text) > 0) then

then call the function, passing it the name of the textbox (or some other
indicator)
and the value in the textbox.

Then, in the function, begin by clearing the contents of the listbox, then
search through the worksheet for the textbox value, and load the listbox.

Your next decision is this: Do you want ALL textbox values to be searched
or just the latest?

For example,
If I enter "Oul" in the First Name box, the listbox  will show  all names
with "Oul" as a first name. If I then enter "Schreiner" in the last Name
box, even though "Oul" is still in the FirstName box, the listbox will
show all "Schreiner's" even if the first name isn't "Oul". If you want
all criteria to be matched, what you should do is:
Check to see if the listbox has contents. If it's empty, search  the
worksheet and populate the listbox. If the listbox has a value, search
through the listbox rows and remove any that do not match the current
criteria. That way, you're "filtering" the previously selected list,
instead of going to the worksheet every time...

Share: 

 

This Question has 5 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on Using Case to do a multi-textbox search Or get search suggestion and latest updates.


Tagged: