2
votes

I have this expression in Reporting Services 16, which return an error as follows:

="--> " & SUM(Fields!entrace_money_value.Value) 
& Microsoft.VisualBasic.Constants.vbcrlf 
& "<-- " & SUM(Fields!exit_money_value.Value)

[rsCompilerErrorInExpression] The Value expression for the textrun ‘Textbox8.Paragraphs[0].TextRuns[0]’ contains an error: [BC30277] Znak typu & neodpovídá deklarovanému datovému typu String. --in Czech

Any help would be appreciated.

2
Try change your '&' to a '+'. - Snowlockk
Are you getting this error in the IDE only, in the reporting portal only, both? The expression is valid, I just tested it. Are you certain the expression above is where the issue is? - R. Richards
I just had a similar issue - it was due to not having a space after a field before an &. There was a return between them but that wasn't good enough for VB. Is there a space after the VBCRLF in your expression? - Hannover Fist

2 Answers

7
votes

I had a very similar looking expression and got the same error code, though the error message mentioned Object instead of String:

[BC30277] Type character '&' does not match declared data type 'Object'

The issue for me wasn't that I was combining strings and integers (which works fine for me, without manual conversion as in the other answer). The issue was that the expression editor does not see line breaks as whitespace.

"-->"
 & Fields!test.Value
& "<--"

In the example above the expression is read as a single line:

"-->" & Fields!test.Value& "<--"

This fails because Fields!test.Value& is invalid syntax.

Adding space characters to the beginning of the next lines (because they are easy to miss at the end of the line) fixes this issue:

"-->" 
 & Fields!test.Value
 & "<--"
3
votes

I can't read Czech but I've made this mistake enough times to know the problem.

Try it this way:

"--> " + CStr(SUM(Fields!entrace_money_value.Value))

SSRS is complaining that you are trying to add together int and a string and it doesn't know what to do. Cast your ints to a string using the CStr function. I also use the '+' operator for these kinds of operations...