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

How to insert number strings and keep data type numeric?

Status
Not open for further replies.

zencalc

IS-IT--Management
Feb 27, 2002
67
US
The report I'm creating has a header I need to define with formulas and parameters. My problem is how to keep a number, for example, 00, or 00401, to display exactly as I type them in? Another example, I have a 15-digit number field that only has 9 digits, so the field should be NNNNNNNNNbbbbbb, where "b" represents blank spaces. It has to be kept as a number data type. If I use a formula and put it in quotations, it keeps the correct digits and/or spacing, but then of course the data type beomes string. Any help here would be greatly appreciated. Thanks.
Brian
 
You should not be typing anything into crystal unless it is a formula field or a parameter field at execution time.

In the case of a formula, enclsing the number with quotes will allow it to be treated as a string.

In the case of a parameter field, make sure the data type is set to string.

If there is another case I missed, please let me know.

Software Sales, Training, Implementation and Support for Exact Macola, eSynergy, and Crystal Reports
dgilsdorf@trianglepartners.com
 
Let me clarify a little more... This report is exported to a csv format and then sent as part of our government-mandated HIPAA-compliance. There are 3-4 header and footer record lines sandwiched around (alot of)member data. I could just manually key a header, but that some of the data in the header relies on date and time, and some of the footer data relies on the report data itself. So, let me ask this question then... if I create a formula field, and enter "00", when I export to CSV is it a number or a string? IF a string, I need some way to get 00, or the other examples I gave to keep numeric format. Is there a way to perhaps fix the number of digit in a field, and fill with zeros if not full? Thanks.
Brian
 
You can explicitly convert numerics to strings and control the number of characters using something like:

totext(23,"000")

Which would return 023

Replace 23 with your field/formula name.

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top