"Input string not in a correct format"

  • [rsRuntimeErrorInExpression] The Value expression for the textbox ‘Calc’ contains an error: Input string was not in a correct format.

    Why is this code to populate the textbox getting that error:

    =IIf(ReportItems!LocalBallots.Value<>"" AND ReportItems!CountyBallots.Value<>"" AND ReportItems!CountyBallots.Value<>"0" AND ReportItems!CountyBilling2.Value<>"",ReportItems!CountyBilling2.Value*2,"")

    The problem is the multiplication sign -- *. If I take out the "*2", it works.

    But I NEED to multiply it by two. What gives -- why is this wrong?

    (I also tried converting it to double using CDbl -- but that in itself gets the same error, even if I take out the *2.)

  • Do you have a NULL? Check for NULL using Dataset!Field.Value Is Nothing. I'd do this in your case:

    =IIF(LEN((ReportItems!LocalBallots.Value &

    ReportItems!CountyBallots.Value & ReportItems!CountyBilling2.Value).ToString().Trim) <> 0 AND

    ReportItems!CountyBallots.Value<>"0", ReportItems!CountyBilling2.Value*2, "")

  • I discovered that IIf statements always evaluate all paths, even if a path is not going to be executed. So even though I check to see if a field is blank, it still tries to multiply the value by 2, even though that path will not be executed.

    I discovered also that there is a Switch statement allowed in RS, so I am going to give that a try and see if it will work better.

  • Interesting find. I knew about switch, but I really dislike the syntax in SSRS.

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply