I'm developing a program in VS02 that displays and exports a CR11 report at a certain screen. It works fine when I hard code the report like this:
vb.net Code:
Dim cryRpt As New ReportDocument() Dim reportPath As String = "ReportPath\ReportFile.rpt" Dim testInt As Integer testInt = TextBox1.Text cryRpt.Load(reportPath) cryRpt.SetParameterValue("InspKey", 123456) CrystalReportViewer1.ReportSource = cryRpt CrystalReportViewer1.Refresh() Try Dim CrExportOptions As ExportOptions Dim CrDiskFileDestinationOptions As New DiskFileDestinationOptions() Dim CrFormatTypeOptions As New PdfRtfWordFormatOptions() CrDiskFileDestinationOptions.DiskFileName = "OutputPath\123456.pdf" CrExportOptions = cryRpt.ExportOptions With CrExportOptions .ExportDestinationType = ExportDestinationType.DiskFile .ExportFormatType = ExportFormatType.PortableDocFormat .DestinationOptions = CrDiskFileDestinationOptions .FormatOptions = CrFormatTypeOptions End With cryRpt.Export() Catch ex As Exception MsgBox(ex.ToString) End Try
But if I change the parameter to a variable as well as the name of the exported report it will show up with no data:I know the report is still receiving the variable as I placed the parameter itself on the report for testing. When the report is run/exported the correct parameter shows up fine. I also have an OLE object on the report that references a dynamic picture file (signature of customer is obtained and created into a .jpg). THAT shows up fine as well and is based on the passed parameter of the report! Anyone have an idea as to why this works hard coded but not with a variable? It's the last part of a project that needs to be done but I'm being driven nuts trying to solve this last issue.vb.net Code:
Dim cryRpt As New ReportDocument() Dim reportPath As String = "ReportPath\ReportFile.rpt" Dim testInt As Integer testInt = TextBox1.Text cryRpt.Load(reportPath) cryRpt.SetParameterValue("InspKey", testInt) 'Changes here CrystalReportViewer1.ReportSource = cryRpt CrystalReportViewer1.Refresh() Try Dim CrExportOptions As ExportOptions Dim CrDiskFileDestinationOptions As New DiskFileDestinationOptions() Dim CrFormatTypeOptions As New PdfRtfWordFormatOptions() CrDiskFileDestinationOptions.DiskFileName = "OutputPath\" & testInt & ".pdf" 'Changes here CrExportOptions = cryRpt.ExportOptions With CrExportOptions .ExportDestinationType = ExportDestinationType.DiskFile .ExportFormatType = ExportFormatType.PortableDocFormat .DestinationOptions = CrDiskFileDestinationOptions .FormatOptions = CrFormatTypeOptions End With cryRpt.Export() Catch ex As Exception MsgBox(ex.ToString) End Try




Reply With Quote
