Error "The name of this field is unknown" (Crystal Reports)

Here is the weird problem I am facing.

My record selection formula is as follows: I tricked her for the purpose of this error:

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

If I copy this exact select statement into Crystal, it previews fine, but when I start with .NET I get

'This field name is unknown.'

The problem occurs in the @ClientName formula @ClientName .

@ClientName just contains:

 formula = {aw_illust.CL1LNAM} 

I can also set it to an empty string (formula = ""), and it still gives

'This field name is unknown.'

Here's the weird part if I get around the formula and put the formula text directly in .NET. Everything is working fine.

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

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

+7
crystal-reports
source share
4 answers

Most likely, you are not using the formula {@ClientName} anywhere in the report; Crystal Reports tends to ignore unused fields, formulas, etc. Place the {@ClientName} field somewhere in the report (heading or some similar section) and suppress it - this way you will not ruin the report design, but CR should know about this formula later.

+2
source share

What syntax has the formula? If this is critical syntax, change it to the basic syntax. Or change the contents of the formula to the syntax of the crystal (without "formula =")

0
source share

You can create a parameter like {?ClientName} and set it from .NET, and then put the selection formula in Crystal as {@ClientName} = {?ClientName} .

0
source share

Can you save the report with the selected selection criteria and then show what the reportDocument class sees using something like:

 TextBox1.text = reportDocument.RecordSelectionFormula 

This will validate your syntax.

0
source share

All Articles