Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Format display of zipcode problem
Message
General information
Forum:
Visual FoxPro
Category:
Reports & Report designer
Miscellaneous
Thread ID:
00638566
Message ID:
00638622
Views:
22
>>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
Nick Neklioudov
Universal Thread Consultant
3 times Microsoft MVP - Visual FoxPro

"I have not failed. I've just found 10,000 ways that don't work." - Thomas Edison
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform