Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Setting a Filter
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00138535
Message ID:
00138752
Vues:
14
>>>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, ;		&& the form
>>>	cAlias				&& the alias we are looking for
>>>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.
>>>
>>
>
>>Why not use a parametized view and pass a parm to the form that is used by the view?
>>
>>Robert
>
>Could do that - but I'm not clear on how to change the parameter while the form is active based on a user selection. How do you requery the view?

David,

Numerous ways to accomplish this.
Example:
You have to set the parm in your view to myDbf == ?m.issueDate
View is called vMyDbf
On your form you have a text box.
The user enters a new date.
On lostfocus() you issue the following:

local m.issueDate, lnSelect
lnSelect = select()
select vMyDbf
m.issueDate = this.value
=requery('vMyDbf')

Thats all there is to it. There are numerous ways to do this, but I think this is a easy way to explain it. If you need more help - just ask.

Robert
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform