Page 1 of 1

How to filter using variable

Posted: Tue Dec 19, 2006 5:42 pm
by Sandy Pham
I want my data band to filter on the field "Incident.Category" = variable.

On the Dictionary pane, I right clicked on Data Sources and chose "New Variable."
I entered a variable with a Name of MyCategory, Type of string and Default Value of Software.

Then I went to my DataBand and added a filter. I chose Expression and then used the expression builder to build:

Incident.Category = {MyCategory}

I also tried:

{Incident.Category} = {MyCategory}

When I preview in the designer, I see all of my records (it ignores my filter request). When I run the preview control, I get an exception saying that a ; is missing. I also tried adding a semi-colon (;) on the end, but I still get the same error.

What am I missing?

How to filter using variable

Posted: Tue Dec 19, 2006 8:12 pm
by Vital
Change Field is to expression, after then in expression field type:

C#

Code: Select all

Incident.Category == MyCategory
VB.Net

Code: Select all

Incident.Category = MyCategory
Thank you.

How to filter using variable

Posted: Tue Dec 19, 2006 10:16 pm
by Sandy Pham
Thanks. One more parameter question, is there a way to set a report parameter so it will allow all of the values in the report.

For example, sometimes I want to display "Open" items, sometimes I want to display "Closed" items and sometimes I want to display all items.

How to filter using variable

Posted: Wed Dec 20, 2006 1:30 am
by Edward
Please provide us with more details about the parameters you want to show or to hide.
What parameters from Dictionary do you want to hide? Did you mean only a filter expression?

Thank you.

How to filter using variable

Posted: Wed Dec 20, 2006 3:02 am
by Brendan
Hi Sandy,

Not sure if this helps but if you want to see all values in the report you can disable the Filter on the DataBand by setting the Property FilterOn to false. When you do want to filter by a particular item ("Open", "Closed", etc) you can set the FilterOn Property to true;

How to filter using variable

Posted: Wed Feb 07, 2007 2:26 am
by Edward
Sandy wrote:I would like to, for example, be able to have 3 report parameters, but allow the user to choose "All" for 1 of them and have that filter not apply (or that filter return all values). Thanks
You can achieve your goal in the following ways:
1. In the filter dialog window of the DataBand you should choose in the Field is combobox an Expression value and to type the following expression there: MyVariable1
MyVariable1 - it is the bool type variable that is defined in the report Dictionary.
Important: ReadOnly checkbox must be checked and the Function checkbox also must be checked when you defining the variable.
The expression of the variable (or in the expression directly of the filter) should be set like this:
(CheckBoxControl1.Checked && (Customers.ContactTitle == "Owner")) ||
(CheckBoxControl2.Checked && (Customers.ContactTitle == "Sales Agent"))

2. Set the following to the BeforePrint event handler of the DataBand:
DataBand.Enabled = MyVariable1; (any expression of the bool type.)

Thank you.