Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Why 'Thisform can only be used in method' error?
Message
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Problèmes
Divers
Thread ID:
00805151
Message ID:
00805384
Vues:
23
John,

As long as you are explicitly running a SELECT inside a method, then you can use this. and thisform. to access properties to build the SQL statement.

When VFP runs the SQL engine on it's own, ie Requery(), RowSourceType = SQL, etc it's running in an environment where this and thisform have no context. It's a bit of a pain but it's easily worked around.

>Andy and Dave, correct me if I'm getting confused, but the bottom line seems to be that THISFORM doesn't work in SQL queries. Yet, the code below (taken from a production application) runs fine:
>
>SELECT DISTINCT ;
> " " + (RTRIM(routeseg.route)+" "+IIF(EMPTY(routeseg.rte_spur),' 00',;
> RTRIM(routeseg.rte_spur))+" "+IIF(EMPTY(routeseg.seg_origin),' 0.00',;
> STR(routeseg.seg_origin,6,2))+" - "+STR(routeseg.seg_term,6,2));
> AS SEGMENTS, ;
> routeseg.seg_origin, ;
> routeseg.seg_term, ;
> PADR(SetCodeVal("JURIS", ROUTESEG.JURIS, "JURIS", "JURISVAL"), 25) AS JURIS, ;
> PADR(SetCodeVal("MNTRESP", ROUTESEG.MNTR, "MNTRESP", "MNTRESPVAL"), 25) AS MNTR ;
>FROM routeseg ;
>WHERE THISFORM.Facility_id = routeseg.fcility_id ;
>ORDER BY seg_term, segments ;
>INTO CURSOR segtemp
>
>This code is wrapped in a form method. Sorry, if it appears as funky as it does in the UT editor. :)
>
>Is there something different about the way this code this code runs when the combo is initializing? Is is possible when the code first runs at initialization that THISFORM.Combo.Value doesn't exist yet?
df (was a 10 time MVP)

df FoxPro website
FoxPro Wiki site online, editable knowledgebase
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform