- Code: Select all Expand view RUN
oDbf:SetFilter( "AGE >= ? .AND. AGE <= ?", { 30, 40 } )
// This sets filter AGE >= 30 .AND. AGE <= 40
// Later
oDbf:ReFilter( { 40, 50 } )
// changes the filter as AGE >= 40 .AND. AGE <= 50
SetFilter( cFilter, bParams )
- Code: Select all Expand view RUN
n1 := 30
n2 := 40
oDbf:SetFilter( "AGE >= ? .AND. AGE <= ?", { || { n1, n2 } } )
// This sets filter AGE >= 30 .AND. AGE <= 40
// Later
n1 := 40
n2 := 50
oDbf:ReFilter()
// changes the filter as AGE >= 40 .AND. AGE <= 50
The following sample uses the second method of using bParams (codeblock) to implement xbrowse with incremental filter on two fields.
- Code: Select all Expand view RUN
- #include "fivewin.ch"
REQUEST DBFCDX
//----------------------------------------------------------------------------//
function Main()
local oDlg, oFont, oBrw, oGet1, oGet2, oDbf
local cName := Space( 20 )
local cCity := Space( 20 )
SetGetColorFocus()
oDbf := TDataBase():Open( nil, "CUSTOMER", "DBFCDX", .t. )
// Parameterized filter with codeblock
oDbf:SetFilter( "UPPER(FIRST) = ? .AND. UPPER(CITY) = ?", ;
{ || { UPPER(ALLTRIM(cName)), UPPER(ALLTRIM(cCity)) } } )
oDbf:GoTop()
DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14
DEFINE DIALOG oDlg SIZE 700,400 PIXEL TRUEPIXEL FONT oFont
@ 22, 20 SAY "FILTER: Name: " SIZE 100,24 PIXEL OF oDlg
@ 20,150 GET oGet1 VAR cName SIZE 150,26 PIXEL OF oDlg ;
ON CHANGE ( oGet1:Assign(), oDbf:ReFilter(), oDbf:GoTop(), oBrw:Refresh() )
@ 22,310 SAY "City: " SIZE 50,24 PIXEL OF oDlg RIGHT
@ 20,380 GET oGet2 VAR cCity SIZE 150,26 PIXEL OF oDlg ;
ON CHANGE ( oGet2:Assign(), oDbf:ReFilter(), oDbf:GoTop(),oBrw:Refresh() )
@ 55, 20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
DATASOURCE oDbf ;
COLUMNS "FIRST", "LAST", "CITY" ;
CELL LINES NOBORDER FOOTERS
WITH OBJECT oBrw
:RecSelShowRecNo()
:bClrSel := :bClrSelFocus
:CreateFromCode()
END
ACTIVATE DIALOG oDlg CENTERED
RELEASE FONT oFont
return nil
//----------------------------------------------------------------------------//