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

Forcing Data Field Type

Status
Not open for further replies.

pgr999

Programmer
Apr 10, 2012
4
0
0
US
I am having an issue with crystal reports changing the data field type based on the information in my .csv file. The field is for zip codes and when the report is generated for addresses in the US it defines the field as a number and Canadian zip codes result in a String[255] definition.
Is there a way that I can force Crystal Reports to always see that field as a string, or would I need to figure out some logic to handle both cases?
 
Are the US zip codes and the Canadian zip codes in different columns on your spreadsheet? If so, how do you have both columns formatted...have you checked to see if the entire column for both is set to text/string?
 
The zip codes are in the same column. When the spreadsheet is sent with US zip codes (eg. 90210) in the Zip column crystal reports defines it as a number. When it is sent with Canadian zip codes (eg. T9E 7R3) it defines zip as a string.
 
Someone suggested that putting the value in quotes in the .csv file will force Crystal Reports to define it as a string even if it has a numeric value. I'm working on testing that now...
 
If it's not a .csv, you can format the entire column as text and that should do the same thing. As far as I know, the "Text" format in Excel should convert any numbers to the ASCII equivalent.
 
The way I've handled this in the past is to have the first line of my csv be a bogus line that I exclude or supress in the Crystal report. I put something like zzzzzzz in the zipcode spot on that bogus first line so Crystal won't try to turn the field numeric.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top