Is it possible to programmatically iterate through a table within a formula in crystal reports?

假如想象 提交于 2019-12-24 08:47:45

问题


Is it possible to programmatically iterate through a table within a formula in crystal reports?

E.G. If I have a master table and a detail table can I iterate through the detail table e.g.

( psuedo code )

local numberVar Total := 0

While not EOF()

IF Type = "+"
    Total = Total + Quantity
ELSE IF Type = "-"
    Total = Total - Quantity
ENDIF

<Next Record>

End While


回答1:


It is possible to use loops in a formula field to get the data that you need, but I have only really used them in complex string manipulation. If you really need to do this then you may be able to look into using subreports, but you'd need to put the subreport in the details section which is not really recommended because it is essentially like running a new report for each record that is pulled.

It sounds like what you are really looking for is a running total field. If you join the master and details tables together the report will pull all of the rows for both tables. Then you can group by "Type" and create a running total field that sums the "Quantity" field for each row and resets on the change of the group. I think it is a little different way of thinking than traditional programming. Hope this helps.



来源:https://stackoverflow.com/questions/1439032/is-it-possible-to-programmatically-iterate-through-a-table-within-a-formula-in-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!