Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Display description in a grid column rather than code
Message
De
01/04/2001 20:34:55
Charlie Schreiner
Myers and Stauffer Consulting
Topeka, Kansas, États-Unis
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00490488
Message ID:
00490791
Vues:
10
Hi Nadya,
I have had the same situation and created a class to handle the translation.
DEFINE CLASS MyCodes AS Relation
   PROCEDURE GetDescription(Code)
      Local RetVal
      DO CASE
      CASE m.Code = "E"
         RetVal = "MyDescription"
      CASE m.Code = "X"
         RetVal = "Other"
      ENDCASE
      RETURN m.RetVal
   ENDPROC

   PROCEDURE GetCode(Descript)
      * More Case Structure Here.
   ENDPROC

   PROCEDURE CodeByNo(Number)
      * Return a code given an integer.
      * A easy was to "FOR X=1 TO N" to 
      * iterate thru the codes for use in 
      * stocking Combos and the like.
      DO CASE
      CASE m.Number = 1
         RetVal = "E"  && Return the first code.
      CASE m.Number = 2 && Return the second code.
      ENDCASE
   ENDPROC
ENDDEFINE
oCodes = NEWOBJECT("MyCodes", "ThisPRG.PRG")
*Use a View as a RecordSource for the GRID. 
SELECT *, PADR(oCodes.GetDescript(Source.Code), 16) AS Descript ;
   FROM Source WHERE ?
You can use DEFINEs and INCLUDEs if you wish, but there's really no reason. Everything to do with using these codes and descriptions should be done here, in this one place.

>>>Hi Barbara,
>>>
>>>The problem here, that I don't have code+description as a separate table. I created an include file, where I set variables, like APNEDT "E", etc. I was thinking, is it possible to set controlsource like iif(APNEDT,APNEDTDESC,...). Since there are ~5 different values, it would not be convenient to use iif, it's better to use some function here. My question is: could it be done?
>>
>>You could set a function as the controlsource of a textbox, which would have that one-char field as a parameter, and return the string.
>
>Could it be a form method? E.g. in properties ControlSource put something like:
>thisform.GetDescription(APN)?
Charlie
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform