2

I'm using ReportViewer for work and I'm trying to get an IIf expression to work with a few text boxes that are using FormatCurrency(). The reason I needed an IIf statement in the first place was because occasionally on this report, there will be null parameters. The example here is a shipping box that may or may not have a value. If it has a value, say 15, it will format correctly to $15.00. If it doesn't have a value it returns #ERROR. Obviously this won't do.

Here is one IIf statement I'm using on a different report that works totally fine (sets the visibility of a text box):

=IIf(Fields!DATASET_NAME.Value.ToString() <> "DELETE", True, False)

Here is the one that's not working:

=IIf(Parameters!ShipAmt.Value.ToString() <> "", FormatCurrency(Parameters!ShipAmt.Value,2), "")

The IIf seems to work because if I enter a value it will still format correctly, but without a value it still returns #ERROR. Any ideas?

4

1 に答える 1

3

null 値で ToString() を呼び出すと Kaboom になります。代わりに IsNot Nothing を試してください。

しかし、本当の答えはここにあると思います。

于 2010-10-19T20:26:49.250 に答える