>>>Hi all
>>>I have a problem with filter command. when i use from below command in my form
>>>
>>>
>>> Select Hesab01
>>> SET FILTER TO GCode = thisform.y_GCode .AND. !EMPTY(KCode) .AND. EMPTY(MCode)
>>> thisform.list2.ControlSource = "Hesab01"
>>> thisform.list2.RowSource = "KName"
>>>
>>>
>>>i get not correct filtered records, but if i change it as below
>>>
>>>
>>> Select Hesab01
>>> filterStr = "SET FILTER TO GCode = " + ALLTRIM(STR(thisform.y_GCode)) + ;
>>> " .AND. !EMPTY(KCode) .AND. EMPTY(MCode)"
>>> &FilterStr
>>>
>>> thisform.list2.ControlSource = "Hesab01"
>>> thisform.list2.RowSource = "KName"
>>>
>>>
>>
>>>my list2 filled with right records. i know it is because of GCode = thisform.y_GCode , but why it is wrong?
>>>thanks for your help
>>
>>If thisform.y_gcode is not fixed then you may really get unpredictable results.
>>Btw, are you sure that you don't confuse Controlsource and Rowsource in your code. Also, using SET FILTER is a bad practice; if possible, it should be avoided.
>
>I dont know what this is mean "thisform.y_gcode is not fixed ".
>I make a property in EDIT PROPERTY/METHOD and set its initial value to 0.
>Hesab01 is my DBF and KName is one of its field. i think it is correct.
>what is your suggestion for SET FILTER ?
>Thanks for your reply
Generally speaking, ControlSource is supposed to be a field, while RowSource could be a table. That's why I assumed that you could make a mistake there.
In regard to SET FILTER, you should not use it. It's much better to populate your list separately. If you have limited number of items then just SELECT them into a cursor, and use it as RowSource, or just scan them and populate ListBox with AddItem or AddListitem.
Edward Pikman
Independent Consultant