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

Incremental Search

Status
Not open for further replies.

AlastairOz

Technical User
Jul 27, 2010
81
AU
I am using code form faq184-3842.
This search only searches on the first column in a list box.
Is there any way to have the search on the second column or even better the first AND second column?
Here is the code I have put in the interactive change of a text box:

thisform.txtSiteList.value = this.value
thisform.txtSiteList.refresh()
LOCAL nCnt, sSearchFor, nLen
sSearchFor = ALLTRIM(this.value)
nLen = LEN(sSearchFor)
FOR nCnt = 1 TO ThisForm.txtSiteList.ListCount
IF sSearchFor == LEFT(ALLTRIM(ThisForm.txtSiteList.List(nCnt)),nLen)
thisform.txtSiteList.Selected(nCnt) = .t.
thisform.txtSiteList.refresh()
EXIT &&Found one
endif
ENDFOR

Any ideas?
 
Incremental Search is rather a name for an automatic feature of comboboxes, but nevertheless, you can modify that code.
.List(Cnt,2) is the value of the second column in the listbox.

So you could serach first OR second column with

Code:
IF ThisForm.txtSiteList.List(nCnt) = sSerachFor OR ThisForm.txtSiteList.List(nCnt,2) = sSerachFor
...
ENDIF

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top