Dan Sorensen
Dan Sorensen

Reputation: 11753

How do you add a comment to a Microsoft Reporting tablix control expression?

Is it possible to add a non-visible comment to the expression in a Microsoft Reporting Tablix Control Expression? If is, how do you do it?

For example, I would like to do something like the following within a tablix expression:

' Only display the spouse last name if it is different.
=IIF(Fields!SLast.Value <> Fields!PLast.Value, Fields!SLast.Value, "")

Upvotes: 1

Views: 806

Answers (1)

Chris Latta
Chris Latta

Reputation: 20560

You can put a comment into an expression, but it has to go at the end. Reporting Services expressions are VBA code but they evaluate to one line of VBA code. This means anything after the single quote ' is treated as a comment.

So your example will only evaluate as text and put that text into the textbox. However, this will work:

=IIF(Fields!SLast.Value <> Fields!PLast.Value, Fields!SLast.Value, "") ' Only display the spouse last name if it is different.

This also works:

=IIF(Fields!SLast.Value <> Fields!PLast.Value, Fields!SLast.Value, "") 
' Only display the spouse last name if it is different.

But beware of this:

=Fields!FirstName.Value + "" 
+ Fields!LastName.Value
' Now add the address
+ Fields!Address.Value

In this example the address will never show because the expression gets put into one line and the address is after the comment ' and so gets commented out. Unfortunately the code highlighter doesn't make this clear and it gets marked up as valid executable code.

Upvotes: 1

Related Questions