I am exporting a Report to PDF the selection criteria works in the sub report with crystal report viewer included with .net. However when I export to PDF the selection criteria only seems to apply to the main report and not any subreports. How do I set the selection criteria for the subreport before exporting to the pdf?
here is the code
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim crReportDocument As ReportDocument
Dim crExportOptions As ExportOptions
Dim crDiskFileDestinationOptions As New DiskFileDestinationOptions
Dim Fname As String
crReportDocument = New RFMSQuote
crReportDocument.DataDefinition.RecordSelectionFormula = "{QuoteKitchen.QuoteID}=" & Int(Request.QueryString("ID"))
Fname = Server.MapPath("Exports\" & Session.SessionID.ToString & ".pdf")
crDiskFileDestinationOptions = New DiskFileDestinationOptions
crDiskFileDestinationOptions.DiskFileName = Fname
crExportOptions = crReportDocument.ExportOptions
With crExportOptions
.DestinationOptions = crDiskFileDestinationOptions
.ExportDestinationType = ExportDestinationType.DiskFile
.ExportFormatType = ExportFormatType.PortableDocFormat
End With
crReportDocument.Export()
Response.ClearContent()
Response.ClearHeaders()
Response.ContentType = "application/pdf"
Response.WriteFile(Fname)
Response.Flush()
Response.Close()
System.IO.File.Delete(Fname)
End Sub
private void GetSubReport(CrystalDecisi
{
CrystalDecisions.CrystalRe
CrystalDecisions.CrystalRe
foreach (CrystalDecisions.CrystalR
{
if (MyReportObject.Kind == CrystalDecisions.Shared.Re
{
MySubReportObject = (CrystalDecisions.CrystalR
MySubReport = MyReport.OpenSubreport(MyS
MySubReport.DataDefinition
}
else
MySubReport = null;
}
}
The this with the subreports are you loop through the main report document and then find it and get a reference to the subreport you found with Opensubreport method
In this code Mysubreport is the subreport report document You can set the selection criteria klike this after that. Hope it helps. If you have more questions let me know
Regards
Emre