>I have two ways that I could use to set a filter in a table in a form's dataenvironment.
>I'd greatly appreciate some comment or suggestions about which way is best or any alternatives
>
>1.. (The old way?)
>oldSel= SELECT()
>SELECT MyAlias
>SET FILTER TO myExpression
>SELECT (m.oldSel)
>
>2.. (Using the DE)
>oCursor= GetCursor(THISFORM, "myalias") && GetCursor defined below
>oCursor.filter= "myExpression"
>
>An interesting difference between 1 and 2 is that 2 moves the record pointer back to the first matching record. SET FILTER never moves the record pointer at all.
>
>
Function GetCursor
>* returns a cursor object from the dataenvironment of the given form and alias
>LPARAMETER oFrm, ;
> cAlias
>LOCAL ARRAY a_Obj[1]
>LOCAL cObj, oObj
>* get array of object names in dataenvironment
>AMEMBERS(a_Obj, m.oFrm.Dataenvironment, 2)
>FOR EACH cObj IN a_Obj
> oObj= EVALUATE("m.oFrm.Dataenvironment."+ m.cObj)
> IF m.oObj.BaseClass = "Cursor" ;
> AND UPPER(m.oObj.Alias) = UPPER(m.cAlias)
> * found it
> RETURN m.oObj
> *<<<<<<<<<<<
> ENDIF
>ENDFOR
>RETURN .NULL.
>
I would go for the first method mainly because it involves much less code.
As to the problem of moving record pointer to the first matching record, you can solve it by issuing GO TOP after SET FILTER TO ...
A moment of silence is our cosmic reset button.