Click here to Skip to main content
15,891,184 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to print twodatabase fields (PinRadius1 and PinRadius2, fields contain varchar data)to a label. If one of the fields is empty (contains no data) I do not need to print that field. If that field contains data I need to put the character "X" in fornt of the number and make sure the number goes out too two decimal places. Here is the expression I am using:

=FormatNumber(Fields!PinRadius1.Value,2) & Switch(Len(Trim(Fields!PinRadius2.Value))= 0, "Switch1: " & Len(Trim(Fields!PinRadius2.Value)), Len(Trim(Fields!PinRadius2.Value))> 0, " X " & FormatNumber(Fields!PinRadius2.Value,2))

If the PinRadius.Value field is empty, I get the following error
"[rsRuntimeErrorInExpression] The Value expression for the textbox ‘PinRadius1’ contains an error: Input string was not in a correct format."

If I remove the FormatNumber command no error. I believe it is a formatting issue. I have tried Google and Yahoo search and no luck. Can any of you help???
thanks,
Posted

Check if the field is empty.

iif(Fields!PinRadius2.IsMissing, true, false)


or try this

iif(IsNothing(Fields!PinRadius2.Value), true, false)
 
Share this answer
 
v4
Comments
ivancyr 27-Jul-11 7:09am    
Lusinike19 this is an "unrecognizable identifier". I am using SSRS 2005. Any other ideas?? thanks
luisnike19 27-Jul-11 10:06am    
Answer updated. my mistake, also I gave u another way to evalute that.
ivancyr 27-Jul-11 10:36am    
luisnike19 this works fine as long as their is data in database field (Example: 25.1) or the field is marked Null. If the field is empty I get an error. Here is the code I am using:
=IIF(IsNothing(Fields!PinRadius2.Value),"True"," X " & FormatNumber(Fields!PinRadius2.Value,2))

Here is the error message I get when the database field is empty:
[rsRuntimeErrorInExpression] The Value expression for the textbox ‘PinRadius1’ contains an error: Input string was not in a correct format.
thank you for your help.

Here is the error message I get when the database field is empty (by empty I mean their is no data in the field or the field is marked
Here is what I found works


=FormatNumber(Fields!PinRadius1.Value,2)&
switch (
Isnothing(Fields!PinRadius2.Value),"",
Len(Fields!PinRadius2.Value) >0, Code.Formatvalue(Fields!PinRadius2.Value)
)


Report Properties/Code
Function FormatValue (ByVal RadiusValue2 as String) as String

Dim TMPRadius2 as String = ""

If Not IsNothing (RadiusValue2) Then

If Not RadiusValue2 = "" Then

TMPRadius2 = Format(CDBL(RadiusValue2) ,"#0.00")
TMPRadius2 = " X "; & TMPRadius2

Else

TMPRadius2 = ""

End If

Else
TMPRadius2 = ""
End If

Return TMPRadius2
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900