none
Passing parameters to a Report Viewer RRS feed

  • Question

  • I am using Visual Basic 2010 and I want to create a report using report viewer where by a user will be able to select the period for the report to be generated. Now I want to pass this selected period values to the report viewer query. How do I achive this?

    Below is the query in the report viewer:

    SELECT

     

     

     

    tbl05_WasteRecord.floatWaste_Cost, tbl05_WasteRecord.floatWaste_Length, tbl05_WasteRecord.floatWaste_Mass FROM tbl05_WasteRecord WHERE txtWaste_Code = 'PPW' AND intChecker = 0 AND dtDate BETWEEN '2010/06/10' AND '2010/12/10'

    Now I want where there are dates I should be using variables that bring values from another VB form where they are selected to the Report Viewer.

    Regards.

    Thursday, February 24, 2011 7:52 AM

All replies

  • Hi,

    Create the crystal report using the fields you have mentioned in the select query.(i..e Place the fields in the Details section of the report).

    In your Visual Basic 2010, place a Crystal Report Viewer control in a page along with two date time picker control which allow the user to select the filter dates

    Crystal Report viewer have a property called ReportSource where you can pass the Crystal Report rpt file object.

    CrystalReportViewer1.ReportSource

    Crystal Report has a Property called SelectionFormula where you can pass you filter Criteria what you have done in Where Statement of the SQL Query.

     Example:

    CrystalReportViewer1.SelectionFormula = {Employees.EmplName}='Mani' and Month({Employees.DOB})=5


    R.Mani http://rmanimaran.wordpress.com
    Friday, February 25, 2011 12:41 PM