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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Crystal Text Field Leading Zero Problem

Status
Not open for further replies.

gmonroesatx

Programmer
Dec 17, 2002
3
US
I am having a problem with a Crystal XI text field suppressing leading zeros and cannot stop it. I created an Access 2007 table from an Excel spreadsheet with no problem. However, when I select one of the text fields which contain numbers (Still a text field) for display in Crystal it is suppressing the leading zeros in the field values.

This field shows in CR XI field explorer as a string 7 characters long, so I thought it should show the leading zeros automatically. It does not show them at all. I have right clicked on the field in the details line and selected to format the field, but I don't find anything in this dialog box which would allow me to "Un-suppress" the leading zeros.

Any ideas would be gratefully appreciated.

Thanks,
Andy
 
Hi,
Format the string to use 0000000 as the format string:
Online_Help said:
The format string "0000.000" produces the string "0125.340" (number of significant digits is less than the number of 0 characters).

You may need top convert the string to a number for particular formatting options..



[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
Hello Turkbear.

Thanks for the reply, but I'm having a hard time figuring out how to format the string within Crystal. Could you give me a little more detail as to where I go to format the string or how to get to an area in Crystal where I can format the string?

I have a 7 character text (string?)field called current_single_app.APP_UNIT. A typical value in the field would be "0267000". This value displays as "267000" in the Crystal detail line. It is not a number field. It was a text field before it was converted into a table. It is still a text field within MS Access 2007. If I right click on this field in the Crystal report and select format field it does not give me a number tab because it is not a number.

So... How do I get to it within Crystal Reports to format the string? Should I create a formula field which uses Cstr() or ToText()to re-convert it to a text field? If so, could you give me an example of that using the field name and the value I gave you?

Thanks again for the reply.

By the way... I have a 4 character text field next to the one above which contains values like "0024" and "0345". This field displays the leading zero or zeros without any special formatting at all. Do you have any idea why one field needs help and the other one does not?

Thanks
 
Hi,
To get to the format you need, convert the field to a number and then use the Totext function to format it...

Code:
@MyOddString
ToText(ToNumber({current_single_app.APP_UNIT}),'0000000')

The only reason I can see for that different behavior in those fields is that they are seen as strings for some reason while the {current_single_app.APP_UNIT} is not.




[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
Turkbear,

Thanks for the syntax example. It works well to display the field values.

Andy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top