This shows some different techniques on searching for data in a table using several different ways. From simple search boxes to utilizing alphabetic buttons to using the OnChange event and other search ways. It also shows a query on how to handle blank valued fields. And how to do date criteria, and also an OR on a field criteria (all in 1 query!) Take the part that works for you. And the last example shows how you can highlight the current record on a continuous form.
Regarding the OnChange search form example, everything I've found uses some complex routine or issues a me.MySearchText.SelStart = me.MySearchText.SelLength command which causes a problem if a space is entered (ie..entering "All State" truncates when you push the space after "All" which makes the searching problematic.) Setting up a complex sql statement or some other complex routine with dozens of lines of code sounded unreasonable and I wanted to do it with 1 very simple query and only 2-3 lines of the simpliest code and method I could find (ie. NO complex Functions)!
So I played around with setting a boolean value to true or false depending on if the spacebar is pushed in the OnKeyPress event for the searchbox. The OnChange event of the searchbox then simply looks at the boolean value and will ignore firing if a spacebar is pushed.
On this search form it also automatically detects the email column of the listbox and is set up so you can quickly locate a name (such as in Outlook), and create an email with a few keystrokes.
Look at the "Sample Business Search Form 2" In this attachment to see how this works.
"Sample Business Search Form 1" is a typical search designed to quickly tab through alphabetical letter buttons.
"Sample Business Search Form 3" and the "Other Search Criteria" forms are some examples showing how you can query a database with blank field values in a search form. No need to write any complex code for searches because you need to search on multiple fields or you have null values in the records - you can do it with a simple expression in 1 very, very simple query!!
"Sample Business Search Form 4" shows you how to quickly select a field name and search for values in that field using the search for every character method. It also uses the up/down arrows in the listbox so you can scroll through the values in the listbox (by simply tabbing to the listbox - no mouse needed to click on the listbox).
There is also a sample form showing how you can highlight the current record you are on in a continuous form.
Again, There's NO complex sql code in any of these examples!! They all use 1 very simple query and only 3-4 lines of easy to understand code in the forms.
It's worth a look.
New version (fixed) and with more options to search by.