0
votes

Assuming that I have two separate reports and I want to show it in a crystal report viewer then print it. I have tried the number 1 solution in this link reference. I put 2 crystal report viewer in my Winforms. then I use the code below but only one report is shown and printed.

Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Public Class frmStPeter
    Private Sub frmStPeter_Load(sender As Object, e As EventArgs) Handles Me.Load
        Dim c As Integer
        Dim doctoprint As New System.Drawing.Printing.PrintDocument()
        doctoprint.PrinterSettings.PrinterName = "EPSON L120 Series on PC1"
        Dim Report As New ReportDocument
        Report.Load("C:\CRep\stPeter.rpt")
        Report.Load("C:\CRep\stAnthony.rpt")
        Dim rawKind As Integer
        For c = 0 To doctoprint.PrinterSettings.PaperSizes.Count - 1
            If doctoprint.PrinterSettings.PaperSizes(c).PaperName = "ClassSchedule" Then
                rawKind = CInt(doctoprint.PrinterSettings.PaperSizes(c).GetType().GetField("kind", Reflection.BindingFlags.Instance Or Reflection.BindingFlags.NonPublic).GetValue(doctoprint.PrinterSettings.PaperSizes(c)))
                Exit For
            End If
        Next

        Report.PrintOptions.PaperSize = CType(rawKind, CrystalDecisions.Shared.PaperSize)
        Report.PrintToPrinter(1, False, 1, 1)
        CR1.ReportSource = Report
        CR2.ReportSource = Report
        CR1.Refresh()
        CR2.Refresh()

    End Sub

End Class

Update. I did it this way. the print was successful but i only view the first report in the report viewer. I cannot find the settings to view my two reports at the same time

Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Public Class frmStPeter
    Private Sub frmStPeter_Load(sender As Object, e As EventArgs) Handles Me.Load
        Dim c As Integer
        Dim doctoprint As New System.Drawing.Printing.PrintDocument()
        doctoprint.PrinterSettings.PrinterName = "EPSON L120 Series on PC1"

        Dim Report As New ReportDocument
        Dim Report1 As New ReportDocument
        Report.Load("C:\CRep\stPeter.rpt")
        Report1.Load("C:\CRep\stanthony.rpt")

        Dim rawKind As Integer
        For c = 0 To doctoprint.PrinterSettings.PaperSizes.Count - 1
            If doctoprint.PrinterSettings.PaperSizes(c).PaperName = "ClassSchedule" Then
                rawKind = CInt(doctoprint.PrinterSettings.PaperSizes(c).GetType().GetField("kind", Reflection.BindingFlags.Instance Or Reflection.BindingFlags.NonPublic).GetValue(doctoprint.PrinterSettings.PaperSizes(c)))
                Exit For
            End If
        Next
        Report1.PrintOptions.PaperSize = CType(rawKind, CrystalDecisions.Shared.PaperSize)
        Report1.PrintToPrinter(1, False, 1, 1)

        Report.PrintOptions.PaperSize = CType(rawKind, CrystalDecisions.Shared.PaperSize)
        Report.PrintToPrinter(1, False, 1, 1)

        CR1.ReportSource = Report
        CR2.ReportSource = Report1

        CR2.Refresh()
        CR1.Refresh()


    End Sub

End Class

Can anyone please help me to solve this. Thank you

1
Only one is shown due to loading the same Report object with both reports, make another Report variable and assign it to the other report.OneFineDay
@OneFineDay, thanks for the comment, i did it this way Code the print was success but i only view the first report in the report viewer. I cannot find the settings to view my two reports at the same time.Diether Silverious

1 Answers

0
votes

Crystal Report 9 doesn't support multiple report view. For example you are using a form name frmView and this form having crviewer 9 and want this form to be used throughout the project. In this regard you print Jv and it has been viewed and again you open cash receipt voucher and click print button but viewer neither open another Tab nor any facility to show both print views in the same viewer. Sorry because its already too late.