[英]No error in formula but when I get to certain page I get a “String is non-numeric” error and I can no longer preview the report
I'm fairly new to programming and am currently teaching myself Crystal Reports... 我是编程新手,目前正在自学Crystal Reports ...
I have a formula that has no errors in it but when I get to a certain page in the report, it gives me a message saying "This string is non-numeric". 我有一个公式,里面没有错误,但是当我进入报表中的某个页面时,它给我一条消息,说“此字符串为非数字”。
Here is the formula, any help is very much appreciated! 这是公式,非常感谢您的帮助!
select {@Upright/Grand}
case "Grand" : if tonumber({scsub.sub_desc}[1]) < 6 then 'Under 6' & chr(146)
else
if tonumber({scsub.sub_desc}[1]) = 6 then '6' & chr(146) & chr(150) & '7' & chr(146)
else
if tonumber({scsub.sub_desc}[1]) > 6 then '7' & chr(146) & chr(43)
default : if tonumber({sccat.cat_desc} [1]) <= 42 then '44' & chr(34) & ' and Under'
else
if tonumber({sccat.cat_desc} [1]) in 45 _to_ 48 then '45' & chr(34) & chr(150) & '48' & chr(34)
else
if tonumber({sccat.cat_desc} [1]) in 49 to 52 then '49' & chr(34) & chr(150) & '52' & chr(34)
You should start by adding a 'else' value in case all your 'if' cases are not verified. 如果所有“ if”用例均未通过验证,则应先添加“ else”值。 Then you should make sure that the {sccat.cat_desc} [1] returns only string values that can be converted to numbers: no nulls, no empty strings, no spaces, no characters, no nothing: just plain numbers.
然后,应确保{sccat.cat_desc} [1]仅返回可以转换为数字的字符串值:无空值,无空字符串,无空格,无字符,无任何内容:仅是纯数字。
Problem is with tonumber
function where you are trying to convert a non numeric value into numeric... hence this error. tonumber
函数的问题在于您尝试将非数字值转换为数字...因此出现此错误。
You have two options: 您有两种选择:
First test the field is numeric or not using IsNumeric
and if the result is true then proceed with your calculation. 首先使用
IsNumeric
测试该字段是否为数字,如果结果为true,则继续进行计算。 Something like this 像这样
if IsNumeric({scsub.sub_desc}[1]) then //your code
Instead of converting the field to numeric value convert the comparision value to String that will be more usefult a less error prone. 而不是将字段转换为数值,而是将比较值转换为String,这将更有用,并且出错率更低。 Somrthing like this.
这样的事。
if {scsub.sub_desc}[1] < ToText(6) then 'Under 6' & chr(146)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.