简体   繁体   English

公式中没有错误,但是当我进入某些页面时,出现“字符串非数字”错误,并且我无法再预览报告

[英]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: 您有两种选择:

  1. 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 
  2. 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.

相关问题 我在水晶报表的公式字段中得到错误? - i get error in formula fields in crystal report? 水晶报告公式中的“字符串是非数字”错误 - 'The string is non-numeric' error in a crystal reports Formula 水晶报表中的字符串是非数字异常 - String is non-numeric Exception in crystal report 在Crystal Reports中将字符串数字转换为十进制时出错:“字符串为非数字” - Error when converting string number to decimal in Crystal Reports: “The string is non-numeric” 尝试将Crystal报表导出到HTML文件时,为什么会出现“无法导出报表”错误? - Why do I get a “Failed to export the report” error when I try to export a Crystal Report to an HTML file? Crystal Reports我收到“加载报告失败”错误? - Crystal Reports I get "Load Report Failed' error? 在打印 Crystal Report 时,我无法预览报告并且它给出了错误消息。 任何人都可以有一个想法吗? 提前致谢 - While printing a Crystal Report I am not able to preview the report and it's giving error message. Can anyone have an idea please? Thanks in advance 我的代码如图所示,并且出现此错误“其余文本似乎不是公式的一部分”&gt; - my code is as shown and i get this error “The remaining text does not appear to be part of the formula”> 从Crystal Report平均值中排除的非数字转换为百分比 - Excluded non-numeric from Crystal Report Average Convert to Percent Crystal Report公式-从字母数字字符获取数字 - Crystal Report Formula - Get numeric from alphanumeric characters
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM