[Crystal Report] Filter records three solutions

Source: Internet
Author: User

Directory:
First, the solution one: report data access using the push model
Second, the solution two: Record the selected formula run time customization
Iii. Solution Three: Merge parameters into records select formula
----------------------------------
Solution One:
Report data access Usage push model

Developers are required to write code to connect to the database, execute SQL commands to create a recordset or dataset that matches the fields in the report, and pass the object to the report. This method allows you to place the connection share into your application and filter the data before Crystal Reports receives the data.
----------------------------------
Solution Two:
Log selected formula run-time customizations

1. Pass the selected formula through the viewer control
[Visual Basic]
Dim Selectformula as String
Selectformula = "{customer. Sales last year} >" & TextBox1 (). Text
Crystalreportviewer1.selectionformula = Selectformula
[C #]
String Selectformula;
Selectformula = "{customer. Sales last year} >" + TextBox1.Text;
Crystalreportviewer1.selectionformula = Selectformula;
[C + +]
string* Selectformula;
Selectformula->concat
("{customer. Sales last year} >", Textbox1->text);
Crystalreportviewer1->selectionformula = Selectformula;

2, pass the selected formula through the report object
[Visual Basic]
Dim Selectformula as String
Selectformula = "{customer. Sales last year} >" & TextBox1 (). Text
Report.DataDefinition.RecordSelectionFormula = Selectformula
[C #]
String Selectformula;
Selectformula = "{customer. Sales last year} >" + TextBox1.Text;
Report.DataDefinition.RecordSelectionFormula = Selectformula;
[C + +]
string* Selectformula;
Selectformula->concat
("{customer. Sales last year} >", Textbox1->text);
Report->datadefinition->recordselectionformula = Selectformula;

3, refresh the corresponding report by using the following line of code to end this code:
Crystalreportviewer1.refreshreport ()
The formula is updated and the new minimum value (sales for the previous year) is used.
----------------------------------
Solution Three:
Merge parameters into a record select formula

Parameter fields need not be placed in a report to be used in a record or group selection formula. Create a parameter field, and then enter it into the formula as if you were inserting other fields.

Record selection with a formula
To reduce the amount of data transferred from the database server and improve performance, merge the parameter fields directly into the record selection formula.
The following record selects the formula to bring the user into the sales quota and only displays all customers with sales exceeding the sales quota last year.
{customer. Sales last year} > {? SalesQuota}

Developers are required to write code to pass parameter values at run time.

The article is reproduced from the network base: http://www.xrss.cn/Dev/DotNet/200852419730.Html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.