Hi Folks,
I'm trying to assign multiple values to a textbox and I'm receiving an error. The error says, "The value expression for the textbox AcctName contains an error." The first value is account number and the second value is account name. An example follows:
1234 - SPC Travel Agency
My expression for the textbox contains the following:
=Fields!AcctNum.Value + ' - ' + Fields!AcctName.Value
Please help.
Hello,
Try this:
=cStr(Fields!AcctNum.Value) + " - " + Fields!AcctName.Value
Hope this helps.
Jarret
|||Hello:
Jarret thanks for responding however, I figured it out by doing the following:
=Fields!AcctNum.Value & " - " & Fields!AcctName.Value
Best regards
|||Yes, that does the same as what I posted, except without the cast for string. Since you didn't include the field type on AcctNum, I went ahead and included the cStr(), just in case it was a numeric field.
Jarret
|||
Jarret wrote:
Yes, that does the same as what I posted, except without the cast for string. Since you didn't include the field type on AcctNum, I went ahead and included the cStr(), just in case it was a numeric field.
Jarret
He used & for string concat, while you used + for integer concat/sum though
I do that all the time in SSRS, using + (in T-SQL) instead of & (in VB)
|||Hello Jerry,
That is true, but the '+' and '&' behave the same when working with strings. Since I casted the field as string, they work the same. The other problem with the expression in his first post was that he was trying to use a single quote (') instead of a double quote (") on the literal string (the dash between the AcctNum and AcctName).
The & does an implicit convert to string on the operators. So, where I did the cast using cStr(), the & handled that itself.
=Fields!AcctNum.Value & " - " & Fields!AcctName.Value
=cStr(Fields!AcctNum.Value) + " - " + Fields!AcctName.Value
Jarret
|||
Jarret wrote:
Hello Jerry,
That is true, but the '+' and '&' behave the same when working with strings. Since I casted the field as string, they work the same. The other problem with the expression in his first post was that he was trying to use a single quote (') instead of a double quote (") on the literal string (the dash between the AcctNum and AcctName).
The & does an implicit convert to string on the operators. So, where I did the cast using cStr(), the & handled that itself.
=Fields!AcctNum.Value & " - " & Fields!AcctName.Value
=cStr(Fields!AcctNum.Value) + " - " + Fields!AcctName.Value
Jarret
Thanks Jarret
That's nice to know that it knows how to interpret the + concat as well
No comments:
Post a Comment