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

ToNumber v7 vs v10 1

Status
Not open for further replies.

damselx

Technical User
Apr 24, 2003
32
AU
I am rewriting a report written in version 7

The formula is ToNumber ({STMAST.BIN_LOCATION}) * {SOTRAN.QUANTITY}

This works fine in version 7, but in version 10 I get an error
'The string is non-numeric'

Anyone have any ideas?

Thanks
Helen
 
I would assume from the message that you have a Location entry which is not expressable as a number - it contains alpha characters for example.
 
Thanks for replying

The bin location has a number in it - ie .47, but the the field is usually used for alpha in the database, hence crystal considers it a string I assume

Although the bin location is designed for alpha there are no alpha characters used in this database
 
Assuming your field contains .47
and NOT .47, (with the comma)
then I can't reproduce your problem. ToNumber works with .47 for me.

I suggest a (maybe temporary) slight modification to the formula to test for a numeric value before you do the multiplication.

if numerictext({STMAST.BIN_LOCATION}) then
({STMAST.BIN_LOCATION}) * {SOTRAN.QUANTITY}
else
0


 
Click on database, verify database and see if this returns the same error.

Software Sales, Training, Implementation and Support for Exact Macola, eSynergy, and Crystal Reports
askdon@srhconsulting.com
 
You can rip the numeric portion out easily enough:

whileprintingrecords;
numbervar Counter;
stringvar TheField:={table.field};
StringVar OutField;
For Counter := 1 to len(trim(TheField)) do(
if isnumeric(mid(TheField,Counter,1))
or
isnumeric(mid(TheField,Counter,1)) = "."
then
OutField:=OutField+mid(TheField,Counter,1)
);
val(OutField)

-k
 
OOps:

whileprintingrecords;
numbervar Counter;
stringvar TheField:={table.field};
StringVar OutField;
For Counter := 1 to len(trim(TheField)) do(
if isnumeric(mid(TheField,Counter,1))
or
mid(TheField,Counter,1) = "."
then
OutField:=OutField+mid(TheField,Counter,1)
);
val(OutField)

-k
 
Lupins - I get an error message 'a number or currency amount is required here' on the 2nd STKM.BIN_LOCATION

Synapsevampire - ummm sorry ... I have no idea what to do with this :)

 
Sorry damselx, I missed out the ToNumber() function by mistake. It needs to be there.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top