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

Fastest incremental search needed

Status
Not open for further replies.
Sep 17, 2001
672
0
0
US
I have 40,000 items I want to incrementally search. I have used a combo grid class but it is slow. (Slow because I use a filter.) I wonder if I am using the wrong appoach to gettting what I want. I don't need to edit the items which is what a grid would be helpful for. I just need to have someone type the item and find the matches available. What would be the fastest way to search the items in a combobox, using a list, table, array, or cursor? I need the list to show the closest matches to the currently typed text. Once item is choosen the item number is stored to a variable for other use.

Examples

Typed: 101
list shows
10100
10101
etc

10165
list shows
10165
10166
10167

Please help!
 
I'm probably not understanding your need completely, but it seems that you can just set IncrementalSearch = .T.

Jim
 
Arrays are the fastest. Get the data into an array and then loop through comparing with the $ operator, populating your combo box for matches. Once you get that up and running, experiment with optimization...(The AT() function instead of $, etcetera...)
 
I tried using a combobox but I could not find a way to get the list to pop down as soon as someone starts typing. What I want is to have them start typing and see closest matches as they type. Then once they see the one they want, click on the item in the list and have that set the controlsource to selected or typed value. Is there a way to pop the list open via a command?
 
Well, there's a dropdown event, which is supposed to be triggered when the down arrow is clicked, but I'm not sure just how to trigger it programatically.

Dave Dardinger
 
To drop down a combo.. in its GotFocusEvent put the code..
KEYBOARD '{F4}'
:) ramani :-9
(Subramanian.G),FoxAcc, ramani_g@yahoo.com
 
Don't we all think this incremental search matter should be embedded in the language?, that is typing a word and show the closest matching records at the top of the list or grid or whatever? like the search we see in windows help?

Unfortunatelly we all must dela with our own methods to get the job done. Here's one I've mentioned before:

The method consist of two objects:

A textbox object
A grid object


Even when we can use many additional code to satisfy our specific needs, the basics are as follow

Write the following code in the Gotfocus event of the textbox

****** beginning of Gotfocus
if this.value=''
select customers &&or the dbf you are using
set order to cname &&where cname is the dbf order
endif
=NUMLOCK(.T.)
=CAPSLOCK(.T.)
****** end of Gotfocus

Write the following code in the InteractiveChange method of the textbox

****** beginning of Interactivechange
select customers
seek alltrim(this.value)
&& set exact off before starting the search
this.parent.grid1.refresh
****** end of InteractiveChange

Have the recordsource of the grid set to customers (I will not explain how to do this since you already know)

The result of the former code is that you will see the closest records shown somewhere in the middle of the grid. I've been trying several methods to have the closest matching records to be the first in the grid (using doscroll) but I' havent been successfull. I hope this helps

rianeiromiron@yahoo.com
 
I got the tip on getting the closest match as the top most record by using teh SET FILTER TO command. Basically you set the filter on the table to be => the value in the text box. Hope this help you also!
 
You are right, one can use "set filter to" but that becomes too slow for dbfs that have lots of records and "large fields", for example customer addresses or large descriptions. This becomes worse if you are showing several fields in the grid. However the "set filter to" aproach might be the right for you if you are using "small" fields.

Anyway, I will post a new separate question in the forum. Check it out for answers. It keeps getting interesting.
 
I did it this way
With thisform.lstnames
.listindex = RecNo()
.topitemid = RecNo()
.refresh
EndWith


This seems to work for moving it to the top of my lstbox and hiliting it

hope it helps

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top