I'm just doing some experimenting with search options when a user types something into a text box.
[snip]

What do you use and why?

I usually use a textbox (but sometimes a combobox) to enter the search term into; a combo box to select search type ("starts with","contains","exact"); in some situations, another combo box to choose the field to search on (sometimes choosing a field to search on sets up a list of allowable options in the search term combobox); and a little "GO" button, which is disabled until the user types something into the search term textbox/chooses an option in the search term combobox.

I put these controls directly onto any form where I need a search, and add a Search() method to the form. Pressing the "GO" button calls the Search() method. The form's Search() method validates the user input and if it's okay, passes it to a nonvisual Search object. (I should make all this into a class at some point--but I've been following the XP technique of getting a few permutations of the input/search/return results pattern working so I can find the common threads, and so far it still looks like refactoring a class out of it will take longer than it does to copy/paste the elements where I need them, and I'm on a deadline to get this thing out the door.)

The Search object takes the user input passed from the form, constructs a suitable query, executes it, and puts the results into a cursor. It then tells the form's Search() that the cursor is ready (or that there were no matches) and that method decides what to do about it.

If there are no matches, the form's Search() method displays a messagebox saying so. Otherwise, the Search() method opens a modal form that displays the matching results in a listbox. The user can double-click the one they want, or highlight it and press a button. Either action closes the modal form and passes the PK of the chosen record back to the calling form. The Search() method then calls the form's method that calls up and displays the chosen record.

Depending on the situation, when there are no matches the user may be given the option of starting a new record. When there are matches, the user may get an option to press a "New" button on the modal results form to signal that none of the search results is what s/he wanted and that a new record should be created instead. Either way, when the modal form closes, the Search() method will then call the normal form method that sets up the display for a new record.

The Search() method can pass various parameters to the results form to determine which buttons are available.

All of this is fairly generic and I've used it in a variety of search situations without having to modify much of anything, except the fields to search on and the allowable options to search for, in cases where that's appropriate.

I don't like to make users open a new window to start a search because in my systems searching is an extremely common task. In many cases, in order to prevent duplications users must search the existing data before they are allowed to create a new record. So having the controls on the same form where the data will be entered speeds things up considerably.

In the past I've also used a system wherein searching for a term immediately displays the first found instance on the form, and the user can keep pressing the search button to display subsequent matches, but most people don't find that as convenient as getting an entire list of matches at once and being able to choose the one they want to view.

Ken Dibble
www.stic-cil.org



_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to