Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Format display of zipcode problem
Message
From
28/03/2002 19:57:16
 
General information
Forum:
Visual FoxPro
Category:
Reports & Report designer
Miscellaneous
Thread ID:
00638566
Message ID:
00638768
Views:
20
God I love you guys! Always a better way to do it....

>>>>But Jim, this is a field on a report, not a form. Is there a way to do this to control the display of a zipcode (stored in the table like: 28314, 238934444, etc) in reports?
>>>
>>>Tracy,
>>>
>>>In that case I would either one of making the field expression;
>>>
>>>
>>>IIF(LEN(ALLTRIM(Zip))>5,TRANSFORM(Zip,"@R 99999-9999"),TRANSFORM(Zip,"99999"))
>>>
>>>
>>>Or preprocessing the data
>>>
>>>
>>>* Code that runs the report
>>>CREATE CURSOR MyRptCsr ;
>>>   ( Fld1 C(20), ;
>>>     ...,
>>>     Zip C(10))
>>>
>>>SELECT TheTableForTheData
>>>SCAN
>>>   APPEND BLANK IN MyRptCsr
>>>   IF LEN(ALLTRIM(Zip)) > 5
>>>      REPLACE Fld1 WITH TheTableForTheData.Something, ;
>>>              ...  WITH ..., ;
>>>              Zip  WITH TRANSFORM(TheTableForTheData.Zip,"@R 99999-9999")
>>>   ELSE
>>>      REPLACE Fld1 WITH TheTableForTheData.Something, ;
>>>              ...  WITH ..., ;
>>>              Zip  WITH TheTableForTheData.Zip
>>>   ENDIF
>>>ENDSCAN
>>>
>>>
>>>Then run the report using MyRptCsr
>>
>>
>>Or even easier, like
>>
>>SELECT * , ;
>>IIF(LEN(ALLTRIM(Zip))>5,TRANSFORM(Zip,"@R 99999-9999"),TRANSFORM(Zip,"99999")) AS formatted_zip ;
>>FROM mytable INTO CURSOR cReportCursor
>>
>
>Or even simplier
SELECT * , ;
> Strtran(TRANSFORM(Zip,"@R 99999-9999"),"- ", "  ") AS formatted_zip ;
>FROM mytable INTO CURSOR cReportCursor
>
.·*´¨)
.·`TCH
(..·*

010000110101001101101000011000010111001001110000010011110111001001000010011101010111001101110100
"When the debate is lost, slander becomes the tool of the loser." - Socrates
Vita contingit, Vive cum eo. (Life Happens, Live With it.)
"Life is not measured by the number of breaths we take, but by the moments that take our breath away." -- author unknown
"De omnibus dubitandum"
Previous
Reply
Map
View

Click here to load this message in the networking platform