mitchel.sellers@gmail.com wrote
is there a particular reason your reports module cannot simply obtain the datasource directly?
Depending on your dataset it would be quite cumbersome to try and share...
I want to try and reeuse the reports module from other modules (with very different datasources). These other modules have datasets that the users filter to display on datagrids. If I can just pass the dataset and the report name to the reports module and I would not have to go to the datasource (again)
My (clumsy )solution was to create a global dataset that gets set by the calling module. The reports module then uses the global dataset to populate its dataset and loads the report (based on the Report Name parameter)
here is the code for the calling module:
======================================================
Private Sub cmdPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdPrint.Click
GlobalVars.DataDS = Me.DataDS
Dim sReportName As String = Server.MapPath(".") & "\DesktopModules\Modules\ReportName.rpt"
Dim params As String
params = "ReturnURLKey=ViewListKey"
Response.Redirect(EditUrl("ReportName", sReportName, "IPReport", params), True)
End Sub
======================================================
from the Report module:
======================================================
Private Sub LoadCrystalReport()
'Load the dataset from the global dataset
Dim ds As New DataSet
ds = GlobalVars.DataDS
Me.Report = New ReportDocument
Dim sReportName As String = Me.ReportName
If FileExists(sReportName) Then
'Load the report
Me.Report.Load(sReportName)
'Set the dataset
Me.Report.SetDataSource(ds)
crvShowReport.ReportSource = Me.Report
crvShowReport.Visible = True
End If
End Sub
======================================================
I am sure there is a better way to this thats why I thought I'd ask here.
thanks
Martin