How to check if SSRS Textbox is empty
Asked Answered
D

7

24

How do you check if a textbox is empty in SSRS 2008? I've tried this code and it doesn't work.

IIF(ReportItems!txtCountVolunter.Value = "", false, true)
Dichy answered 5/10, 2012 at 2:7 Comment(0)
T
38

Try the following:

=IIF(Len(ReportItems!txtCountVolunteer.Value) <= 0, true, false) 
Tertullian answered 5/10, 2012 at 12:16 Comment(1)
=Len(ReportItems!txtCountVolunteer.Value) <= 0 is enough actuallySecretary
T
20

You should use this expression

=IIF(IsNothing(Fields!UserEmail.Value) OR Fields!UserEmail.Value = "",
 "Empty", "Not Empty")

The first: IsNothing(Fields!UserEmail.Value) checks if the field value is NULL The second: Fields!UserEmail.Value = "" checks of the filed value is blank ""

So you need both of them in order to check if the value is either null or empty.

Tiffie answered 5/10, 2012 at 12:36 Comment(0)
W
3

Try the IsNothing function like this:

IIF(IsNothing(ReportItems!txtCountVolunter.Value), "empty", "not empty")
Workman answered 5/10, 2012 at 2:58 Comment(0)
I
3

Check for null

=IIF(IsNothing(ReportItems!txtCountVolunteer.Value),true, false) 
Ioves answered 9/2, 2013 at 11:57 Comment(0)
T
2

While the answers before this are correct, they are a bit redundant. Just this will suffice:

=String.IsNullOrEmpty(Fields!txtCountVolunteer.Value)

To identify if the value is not empty:

=NOT String.IsNullOrEmpty(Fields!txtCountVolunteer.Value)

If you are using the expression to dictate visibility, keep in mind that the Expression should evaluate to true when the field should be hidden (it defaults to visible). It took me the better part of an hour troubleshooting my own expression before I realized that.

In my example, I am hiding the Lot Number if I have an empty or null string value: Visibility Expression Screenshot

Toinette answered 16/2, 2021 at 20:55 Comment(0)
A
0

For those who come from a .NET world and you want to check non-empty and say for argument sake want the value 0 instead of blank!

=IIf(String.IsNullOrEmpty(ReportItems!txtCountVolunteer.Value), 0, ReportItems!txtCountVolunteer.Value)
Aspirin answered 18/4, 2018 at 0:26 Comment(0)
A
0

You can do this if you use conversion and empty value in your dataset (I have stored procedure as source):

=CInt(IIF(Parameters!Seller_id.Value = "" , "-1" , Parameters!Seller_id.Value))  

and then in stored proc add condition

([some_field]=@param or @param=-1)
Apul answered 13/8, 2021 at 5:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.