Crystal Reports Viewer to handle multiple reports

Bufedog

Member
Joined
Nov 20, 2006
Messages
16
Programming Experience
1-3
I have created a crystal reports viewer that handles multiple reports, but I have not been able to figure out how to pass the report objects as a parameter in the method. If I want to pass different types of report objects, what is the abstraction?
 
I want to create a method that accepts as a parameter a crystal report object. This crystal report object will be the reportsource for the viewer. How do I abstract to accept different reports as the parameter?
 
I'm not sure I have enough information to give you the best answer. There are several way to skin this cat. In the past I set up a string variable to hold a short name of the report selected. Then when it comes time to fill the report viewer, I use a Case/Select or 'IF' statements based on that string.

VB.NET:
        If RepString = "MonthlyAcc" Then
            Dim MyReport As New MonthlyReportName
            MyReport.SetParameterValue("ParameterName", ParmValue)
        Else
            If RepString = "YearlyAcc" Then
                Dim MyReport As New YearlyReportName2
                MyReport.SetParameterValue("ParameterName", ParmValue)
            End If
        End If
        CRviewer1.ReportSource = MyReport
or this way...

VB.NET:
        Select Case RepString
            Case "MonthlyAcc"
                Dim MyReport As New MonthlyReportName
                MyReport.SetParameterValue("ParameterName", ParmValue)
            Case "YearlyAcc"
                Dim MyReport As New YearlyReportName2
                MyReport.SetParameterValue("ParameterName", ParmValue)
            Case Else
                  'Statements executed if  no Case value is = variable
        End Select
        CRviewer1.ReportSource = MyReport
If that isn't what you want, let me know...
 
Sorry I've been so long in replying. I finally go this to work by establishing a property that was a ReportDocument object. I passed the reportdocument object to the display form and it worked fine.
 
Back
Top