Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to format table1.field1 based upon tabl1.field2 ?

Status
Not open for further replies.

yehong

Programmer
Sep 22, 2003
291
US
I have to format a field based upon another field.
Here is an example:

Table1.Field1 Table1.Field2
234 0,000.00
123ST Text
1256 0.0%
444455 0.00%
1145 0.00 and so on.

So,
if the format in table1.field2 say =0.0%, then 1256 should be displayed as 1256.0%.
if table1.field2=text then "123ST"
if table1.field2=0.00% then 444455.00%
like this. There are unknown number of formates.
Is there a way to do this in crystal?
Thanks,
 
Why are there an unknown number of formats? Why not run a report, grouping on {table1.field2} to get a list of possible formats? Then you could create a select case formula like this, assuming that {table1.field1} is a string:

select {table1.field2}
case 0,000.00 : totext(val({table1.field1}),2)
case Text : {table1.field1}
case 0.0% : totext(val({table1.field1},1)+"%"
case 0.00% : totext(val({table1.field1},2)+"%"
case 0.00 : totext(val({table1.field1},2)
default : {table.1.field1};

Not sure this will work, since I can't really test it, but it might be worth a try.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top