'This field name is not known' error (Crystal Reports)

好久不见. 提交于 2020-01-02 01:27:04

问题


Here is a strange problem I have run into.

My record select formula is as follows, I have dumbed it down for purposes of this error:

reportDocument.RecordSelectionFormula = " {@ClientName} = 'Smith' "

If I copy this exact selection statement into Crystal it previews fine, but when run from .NET I get

'This field name is not known'.

The problem is occurring at the @ClientName formula field.

@ClientName simply contains:

formula = {aw_illust.CL1LNAM}

I can also set it to just a blank string (formula = "") and it still gives

'This field name is not known.'

Here is the strange part, if I bypass the formula and put the formula text straight into .NET everything works fine.

reportDocument.RecordSelectionFormula = " {aw_illust.CL1LNAM} = 'Smith' "

That is the same record selection, except with the '@ClientName' formula replaced with '{aw_illust.CL1LNAM}'. It just happens on this one report, I have many other Crystal Reports working with formulas referenced in .NET just fine. Any ideas?


回答1:


Most likely you are not using your {@ClientName} formula anywhere on report; Crystal Reports tends to ignore unused fields, formulas etc. Place {@ClientName} field somewhere in report (header or some similar section) and suppress it - this way you don't mess up report design, but CR should know about that formula afterwards.




回答2:


Which syntax has the formula? If it is crystal syntax then change it to basic syntax. Or change the content of the formula to crystal syntax (without "formula =")




回答3:


You could create a parameter like {?ClientName} and set that from .NET, and then put a select formula in Crystal like {@ClientName} = {?ClientName}.




回答4:


Can you save the report with the selection criteria you'd like then display what the reportDocument class sees using something like:

TextBox1.text = reportDocument.RecordSelectionFormula

This would confirm that your syntax is correct.



来源:https://stackoverflow.com/questions/2135030/this-field-name-is-not-known-error-crystal-reports

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