Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Filter, Form and Variables
Message
 
 
À
01/09/2008 18:21:16
Jay Johengen
Altamahaw-Ossipee, Caroline du Nord, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Versions des environnements
Visual FoxPro:
VFP 9 SP2
Divers
Thread ID:
01343935
Message ID:
01343973
Vues:
23
>>>I had a similar issue a week or so ago, but thought I had worked around it. I need to use a filter. The filter changes depending on the value of variables. I know that the variable go out of scope if they are defined in the INIT (or seem to anyway). The filter does not like using THISFORM in the condition. What is the best solution? If it is making a reference to THISFORM and using that, how do I do that? I tried a couple things, but it kept saying that I could not redefine THISFORM.
>>
>>Jay,
>>
>>Here is one of the solutions.
>>
>>lcFilter = "myIntField = " + transform(thisform.IntegerField)
>>
>>
>>or
>>
>>lcFilter = 'myCharField = "' + thisform.CharField + '"'
>>
>>set filter to &lcFilter
>>
>
>Why can't I just set m.FilterCondition to whatever I want in my code and then do SET FILTER TO &FilterCondition when I need to? The problem I seem to be having now is I can't keep a variable in scope that I define in the INIT (understand that is not supposed to work) or the LOAD (which I thought was supposed to work). By the time I get to a method in the form, m.FilterCondition is not understood to be defined.
>
>Sorry, I forgot to say that I decided not to use a form property and am using a variable instead. Scoping seems to be the issue right now.

You are correct, memory variables with the default scope of LOCAL go away when the procedure they are defined in ends. This includes INIT and LOAD methods. The approaches suggested by Naomi and Jim will both work. If you decide to stay with a filter, don't forget that it only takes effect when you move the record pointer. (And in that case, use LOCATE with no parameters instead of GO TOP -- it's optimizable).
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform