>>>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
USE (mtable) IN 0
SELECT (mtable)
SET FILTER TO &mFilter
Does work.
Cetin