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

Datatype appears as String when its defined as a Number

Status
Not open for further replies.

huytonscouser

Programmer
Oct 14, 2011
88
US
I have a field which is a number(its a formula created from a number field in an oracle 10g db i.e. {table.field}/1024/1024), when i export the report to .xls or .xlsx and verify in excel it is a number, and i sum, etc, etc.
But whenever i try and create a report with the same .xls or .xlsx(defined via a odbc) the field type is always string. the field is defined in crystal as number -1123.00. I've tried leaving as "system default number format"

I have other number fields in the report, they export fine.

i'm baffled.

thanks for any help.

 
Crystal does many things for you, mostly things you want, but occasionally not. Sometimes it gets a fixed idea and will not be moved.

I'd suggest creating a formula field and using ToNumber to confirm its data type.

[yinyang] Madawc Williams (East Anglia, UK). Using Crystal 2008 with SQL and Windows XP [yinyang]
 
After investigation, this is the problem.
The field in oracel is indeed a number and so is the resulting formula {table.field}/1024/1024
But the oracle field can contain a null value, and if that null value is in the 1st row, then the field/my formula is
defaulting to a string when exported.

when i make my formula

if isnull({table.field}) then 0 else {table.field}/1024/1024)

the problem is resolved.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top