Author | Topic: Complex DbSetFilter() | |
---|---|---|
Itai Ben-Artzi | Complex DbSetFilter() on Fri, 20 Apr 2018 10:35:06 -0700 Hi, Is it possible to set a filter of one table base on a field in another table? How? For example: USE Customer NEW EXCLUSIVE INDEX ON CustNo TO CustNo SET INDEX TO CustNo USE Invoice NEW DbSetRelation( "Customer" , ; {||Invoice->CustNo} , ; "Invoice->CustNo" ) Invoice->(DbSetFilter( {|| Costomer->STATE='CA' })) Many thanks, -Itai | |
Jonathan Leeming | Re: Complex DbSetFilter() on Fri, 20 Apr 2018 12:03:08 -0600 On 4/20/2018 11:35 AM, Itai Ben-Artzi wrote: > Hi, > Is it possible to set a filter of one table base on a field in another > table? How? > For example: > USE Customer NEW EXCLUSIVE > INDEX ON CustNo TO CustNo > SET INDEX TO CustNo > > USE Invoice NEW > DbSetRelation( "Customer" , ; > {||Invoice->CustNo} , ; > "Invoice->CustNo" ) > > Invoice->(DbSetFilter( {|| Costomer->STATE='CA' })) > > Many thanks, > -Itai > Hi Itai, I had never tried it so your question made me curious as to whether the code block is evaluated just once or with every movement of the record pointer so I wrote a quick test. The following code caused a "beep" with each DBSKIP() so I guess you can. FUNCTION FilterTest() DBOpen("Lookup","Lookup") DBSETFILTER({||TONE(3000,2),.T.}) Lookup->(DBGOTOP()) Lookup->(DBSKIP()) tdPause(50) Pause 50/100 of a second Lookup->(DBSKIP()) tdPause(50) Lookup->(DBSKIP()) tdPause(50) Lookup->(DBSKIP()) tdPause(50) Lookup->(DBSKIP()) tdPause(50) Lookup->(DBSKIP()) tdPause(50) DBClose("Lookup") tdMsg("Done") RETURN NIL jonathan.leeming@the-family-centre.com Edmonton, Alberta, Canada | |
Itai Ben-Artzi | Re: Complex DbSetFilter() on Sun, 22 Apr 2018 01:25:36 -0700 Good idea! Thank you Jonathan. | |
Anand Gupta | Re: Complex DbSetFilter() on Sat, 21 Apr 2018 12:20:27 +0200 Itai Ben-Artzi wrote in message news:519kddlg6fdlf9eplka3umukegavshg4m3@4ax.com... >Hi, >Is it possible to set a filter of one table base on a field in another >table? How? >For example: > USE Customer NEW EXCLUSIVE > INDEX ON CustNo TO CustNo > SET INDEX TO CustNo > > USE Invoice NEW > DbSetRelation( "Customer" , ; > {||Invoice->CustNo} , ; > "Invoice->CustNo" ) > > Invoice->(DbSetFilter( {|| Costomer->STATE='CA' })) > >Many thanks, >-Itai Yes it works, from Clipper time. I use it. for example, set filt to scod == smast_pty->scod Regards, Anand |