Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SetFilter()
Message
De
15/02/2003 13:17:13
 
Information générale
Forum:
Visual FoxPro
Catégorie:
CodeMine
Titre:
Divers
Thread ID:
00753658
Message ID:
00753737
Vues:
27
Hi Ivan:

>Using the Select, it seems I must use it evey time to refresh the filter. If I use the select once, lets say in the AfterOpen, only refreshing the grid in the control's AfterChange won't have any effects. The select won't create a filter, right ? I need to Select every time the Control's AfterChange fires. OK ?

Calling the cursor's Select() method will effectively apply a Foxpro SET KEY TO command creating an index based filter using the date you have supplied. The cursor will stay this way until your user types in another date he/she wishes to filter on. So, you only have to call the Select method when your date changes. But then this is the same case when you use SetFilter(). If you change the filter date, you have to change and therefore re-apply the filter too.

>m.oCursor.SetFilter('dtos(DateFieldName) = DTOS(thisform.dDate)')

This is an incorrect call because you are passing a literal string, part of which, the method will not understand. The following should work :-
m.oCursor.SetFilter('dtos(DateFieldName) = ' + DTOS(thisform.dDate))
The first part of the argument is constant but you must literally evaluate the second (variable) part, in otherwords, pass the actual value. So, the SetFilter method would receive a string that looks like this (assuming the value of thisform.dDate = today) :-
'dtos(DateFieldName) = "20030215"'
This, it should be able to evaluate. However, remember that each time the user changes the date, you will still have to reapply the filter.

>When would be the right time to use it ?

When you have an index available that equates to the value you wish to filter, then a native Foxpro SET KEY TO command will always be faster than a SET FILTER TO. As the Codemine CursorObject.Select() method effectively does a SET KEY TO, then this will be the fastest for what you are presently trying to achieve. Try it on the cursor by itself. It is miles faster than the SET FILTER expression.

However, SET FILTER can work where there are no indexes and/or you can create some quite esoteric expressions across mutiple columns in the table and SET FILTER will work.

In the example you have cited, its a no-brainer. Use the Select method.

HTH
-=Gary
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform