Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Why does SET FILTER TO not accept variables?
Message
De
01/12/1998 00:41:10
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
30/11/1998 16:21:10
Information générale
Forum:
Visual FoxPro
Catégorie:
Classes - VCX
Divers
Thread ID:
00162388
Message ID:
00162662
Vues:
20
>>>Hello,
>>>
>>>I am using Visual FoxPro 6.0. I have created a class with a listbox on it which uses a table. I want to set a filter on it which is given by another method outside the class using a parameter. Now I am using the next code:
>>>
>>>LPARAMETER mFilter && mFilter = 'value'
>>>
>>>USE table IN 0
>>>SELECT table
>>>SET FILTER TO table.field = '&mFilter'
>>>
>>>This is working.
>>>
>>>But now I don't want to define the table.field in the class. I have tried the next code, but that does not work.
>>>
>>>LPARAMETER mtable, mFilter && mFilter = "table.field = 'value'"
>>>
>>>USE mtable IN 0
>>>SELECT mtable
>>>SET FILTER TO mFilter
>>>
>>>This code is not working because FoxPro can not find variable mFilter.
>>>When I use a WAIT WINDOW to display the value of mFilter the value is right.
>>>
>>>Can anyone help me with this problem? Thank you in advance.
>>Afier,
>>mFilter is an expression, not variable + you'll face scope problem :
>>mFilter = "Somefield = m.SomeValue"
>>You could say :
>>set filter to &mFilter
>>But here filter would need to access "m.SomeValue" variable. So better m.SomeValue should be a public var or custom form property.
>>Neverthless, you may do it right but OTOH the expression is Rushmore optimizable or not, "set filter" is awfully slow. I would suggest trying something different (a view, a cursor, set key etc)
>>Cetin
>
>Thank you for all of your answers, but I already tried these things. It still does not work. Do you have any other suggestions?
>
>Thanks in advance for your time.
Afier,
In a class or not "set filter to" works. Now based on your first working example :
LPARAMETER mtable, mFilter    && mFilter = "table.field = 'value'"
USE (mtable) IN 0
SELECT (mtable)
SET FILTER TO &mFilter
Does work.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform