Click here to Skip to main content
15,845,742 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have a CR report that I am designing and I have all of my fields from the database. The database is a large one but all of the data has a year in it. I want to print out year 2014 data for a user, how will that go? Example:
XML
User | Car Miles | Walk Miles | Run Miles | Year |
100  | 2000      | 3000       | 1000      | 2012 |
100  | 800       | 74         | 520       | 2013 |
100  | 500       | 88         | 528       | 2014 |


So, on the report I just want the report to display all the data that has the Year 2014. Can this be done on CR 2013?
Posted

1 solution

Yes, you can use Selection Formula to filter your data in CR
C#
string selectFormula = "{Report.Fieldname} = 2013 ";
crystalReportViewer.SelectionFormula = selectFormula;

you can pass the Year like this also
C#
int year = 2013;
string selectFormula = "{Report.Fieldname} =" +year;
crystalReportViewer.SelectionFormula = selectFormula;

Some useful information can be found from here and here
 
Share this answer
 
v2
Comments
Computer Wiz99 29-Oct-14 8:22am    
The code you gave is for the code behind right? What about on the program that makes a CR? I have reports that I designed in SAP CR 2013. Is there a formula that I can put together like in Formula Fields to filter out the year I need?
Dilan Shaminda 29-Oct-14 9:28am    
yes it is for codebehind.you can add selection formulas in CR too
check these links

Record Selection

Customizing Record Selection Formulas
Computer Wiz99 29-Oct-14 9:36am    
Thanks. This will help out a lot.
Dilan Shaminda 29-Oct-14 9:37am    
you are welcome :-)
Computer Wiz99 29-Oct-14 12:36pm    
Where do I enter the filter formula for the Year in CR v2013?

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