>FUNCTION SCOPE (cDbf,cField,xStart,xEnd) >select (cDbf) >set filter to between((cField), xStart, xEind) >ENDFUNC >>This function is not working, I'm doing something wrong.
>scope("year","date", {^2001-01-01}, {^2001-30-01}) >>
FUNCTION SCOPE (cDbf,cField,xStart,xEnd) LOCAL lcFilterString SELECT (cDbf) DO CASE CASE TYPE("xStart") = "D" lcFilterString = "set filter to between("+cField+",{"+DTOC(xStart)+"},{"+DTOC(xEnd)+"})" CASE TYPE("xStart") = "C" lcFilterString = "set filter to between("+cField+",'"+xStart+"','"+xEnd+"')" CASE TYPE("xStart") = "N" OR TYPE("xStart") = "I" lcFilterString = "set filter to between("+cField+","+xStart+","+xEnd+")" ENDCASE *-- Set the filter on selected table &lcFilterString ENDFUNCThe call to the routine stays the same. The only requirement is that both variables to check must be of the same type. You might want to add more checking, I assumed you might want to use it for more than just filtering on date fields.