Thanks Gavin. I never though the variable scoping is the problem. I just use form properties and it works fine now. Thanks!
>Hi John,
>
>The reason that it falls over is because the variable scoping for VALUE2 has disappeared once the VALID has executed ( I'm assuming that VALUE2 is a variable defined as LOCAL in the VALID), so each time the FILTER is evaluated it's looking for VALUE2 which no longer exists.
>
>I get around this problem by doing something like
>
>cCommand = "SET FILTER TO field1 = " + value1 + " AND field2 = " + value2
>&cCommand
>
>Hope this helps.
>
>Gavin...
>
>>In VFP5, in the command window, I could type:
>>
>>SET FILTER TO field1=value1 AND field2=value2
>>
>>and the filter works as it should. However, if I put the same code in Valid method of a textbox on a form I get an error:
>>
>>"Variable value2 not found". The variable does exist 'cause I set this just prior to the SET FILTER command. Is this a bug or something? It only works if I SET FILTER TO only one condition.
>>
>>I don't use SET FILTER very often (if at all) but for this instance but it should work nonetheless. Pretty weird.
It's "my" world. You're just living in it.