2011-12-19 63 views
0

我想在水晶报表中显示一些记录。为此,我需要计算总和字段。我需要计算一个字段在sql表中的总和,我需要使用where子句。 在晶体报告的fomula区间i写在textobject中的水晶报表中计算总和

{open}+{{#RTotal1}- {#RTotal0}} 

其给出错误。 open是一个textobject。我在这里出错了。

开放Itextobject的值从VB形式的文本框,通过使用此

DirectCast(GL2.Section2.ReportObjects("open"), CrystalDecisions.CrystalReports.Engine.TextObject).Text = TextBox8.Text 

我认为这个问题是textobject和fieldobject之间式通过。我错了什么?我该怎么做。

回答

0

我假设{open}被用作文本字段而不是数字。 Crystal报表具有一个称为ToNumber的功能,可将数字文本转换为数字。

您将需要您的公式更改为:

ToNumber({open})+{{#RTotal1}- {#RTotal0}} 

与晶体的一切;尽量安全地发挥防止错误的作用;我会用:

if NumericText({open}) and not isnull({open}) then 
    ToNumber({open})+{#RTotal1}- {#RTotal0} // text is numeric - use it. 
else 
    ({#RTotal1}- {#RTotal0}) // test is not a number, ignore it.