Steve Hobbs
Steve Hobbs

Reputation: 131

SSRS VB IIF statement returning error for NULL value

Im wondering if some can help we understand why SSRS returns Error in the my Textbox13 text box.

Warning 1 [rsRuntimeErrorInExpression] The Value expression for the textrun ‘Textbox13.Paragraphs[0].TextRuns[0]’ contains an error: Conversion from string "NULL" to type 'Date' is not valid.

The value Workorder_Closed_Date is a result of a sql query, and is either filled in or NULL

=IIF(IsNothing(Fields!Workorder_Closed_Date.Value),
    reportitems!Textbox13.Value="open",
    reportitems!Textbox13.Value="closed")

Upvotes: 1

Views: 910

Answers (1)

Mathieu Guindon
Mathieu Guindon

Reputation: 71157

If that expression is for Textbox13, then this would work:

=IIf(IsNothing(Fields!WorkOrder_Closed_Date.Value), "open", "closed")

Note that IIf executes both true and false parts, so you want a constant expression in each branch of the condition, not side-effects.

=IIf(condition, value_if_true, value_if_false)

Oh god.

Warning 1 [rsRuntimeErrorInExpression] The Value expression for the textrun ‘Textbox13.Paragraphs[0].TextRuns[0]’ contains an error: Conversion from string "NULL" to type 'Date' is not valid

Your value isn't null (or Nothing actually) - it's a STRING literal that contains the VALUE "NULL".

You need to fix your data, not your report.

Upvotes: 3

Related Questions