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

MULTI CRITERIA FILTERING

Status
Not open for further replies.

spysab

IS-IT--Management
Jun 13, 2019
27
PH
Hi Guyz!

I have this code as my filter

Code:
 LPARAMETERS tcFieldName, tcSearchText

tcSearchText = ALLTRIM(UPPER(tcSearchText))

&& use macro expansion to implement search filter
SET FILTER TO "&tcSearchText" $ UPPER(&tcFieldName)

GO TOP
thisform.Refresh()

and have this in my textbox search

Code:
 LOCAL cField, ctext, nItem
** get the selected field item#
** .aflds is created method
** .setfilter is created method

nItem = thisform.cboField.ListIndex
IF EMPTY(thisform.aflds[nItem,2]) then
	cfield = thisform.aflds[nItem,1]
ELSE
	cfield = thisform.aflds[nItem,2]
ENDIF

** get value to search for
ctext = thisform.txtsearchText.Value

** call the filter routine (method)
thisform.setfilter(cField, cText)

this allows me to filter data base on cbofield then textsearch..
but how can i make another filter like cbofield AND cbofield2 so i can filter contact and address at once.
 
Hi,

I would instead of Set Filter use a cursor for my combobox.
In that case you will have to built your cursor someting like
Code:
select name, address from myTable into cursor curCbo where id > 10
Or whatever other condition you would like to built your cursor.
You can make the where expression as complicated as you need.

Koen
 
I already said so in thread184-1795413:

VFP also has a very general filter form example as the _filterdialog class. You can look into it with
Code:
Modify class _filterdialog of Home()+"ffc\_table"

This'll be over the top, but it can give you an idea of how complex this becomes when you don't just add new conditions with AND, want to enable different operators, etc.

There is no simple ADD FILTER command, so you need to keep filter conditions in mind and in the simplest case create the new filter condition as if you would replace the old, put that into lcNewFilter and then make the overall filter condition lcOverallFilter = "("+ lcOldFilter +") AND "+lcNewFilter. And then lcOverallFilter has to be applied and stored for reference when the next condition is added.

Bye, Olaf.

Olaf Doschke Software Engineering
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top