formula error when having empty DataSource

2019-04-02 11:52发布

I am using crystal reports in my asp.net application of vs2012. I have a formula in group of datasource that is:

if( {PB_Portal_Reports_RestrictionRepClass.Amount}>0)then t:= ToText({PB_Portal_Reports_RestrictionRepClass.Amount}) +" "+{PB_Portal_Reports_RestrictionRepClass.Currency} else t:= "xxx";

when I have at least one record the report is working as needed, but when I pass list with number of records =0, then I have an error

A string is required here. Details: errorKindError in File CollectionListReport {E78D7A32-A1D9-4C39-B11A-C333992049DC}.rpt: Error in formula amn: 'if( {PB_Portal_Reports_RestrictionRepClass.Amount}>0)then' A string is required here. Details: errorKind

I tried to use isnull, or type conversion, or even tried to check first some other variable "has_data" and only then try to do this comparision but still had no luck in solving this error, please help me

1条回答
聊天终结者
2楼-- · 2019-04-02 12:27

Andrei,

Why are you converting to text here?

 t:= ToText({PB_Portal_Reports_RestrictionRepClass.Amount})

I think you should be fine with just using

t:=({PB_Portal_Reports_RestrictionRepClass.Amount})

Give that a try and let me know if it works.

Cheers,

Chris

查看更多
登录 后发表回答