This is a migrated thread and some comments may be shown as answers.

Issues with ReportBook

1 Answer 66 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 2
Bob asked on 11 Apr 2014, 09:49 PM
Hi there -

I am thoroughly frustrated with the reporting tool.  I have been working on a voucher statement project for some time and experiencing that the reporting tools do not simple things you would think it would do.  I have made design changes to reports to work around printing issues, however I find myself having other issues.  Therefore, I am currently experiencing several issues and I will try to explain them as best I can.

To describe what the project entails, this is a simple reporting solution for printing credit vouchers.
I get a list of payment numbers to read and process a statement page, and credit voucher for each payment.

I am using a report book to add the reports as they are processed, so I can print them as a whole.
The sequencing of the entire report book should be as follows:

1 -  Header Report (Displays general text)

2 -  Credit Voucher Statement (A list of details that make up the voucher)
3 -  Actual Credit Voucher (Single Page coupon)

NOTE: If there are multiple payment numbers, I print reports 2 and 3 in a loop, adding them to the report book as they are processed.

4 - Summary report (Shows all the credit vouchers that were printed and other summary information)

The reports print on a duplex printer, although I try to modify that setting depending on which report is printing. 
Each report should start on a fresh sheet of paper (Which it does not currently do well.)

In the code (below), I loop through the payment numbers and pass the correct parameters to the reports.
However, when adding reports 2 and 3 to the report book, the first payment number gets repeated for the total number of payments listed.
When the summary report is printed, it too only prints the summary for the first record. 

Even when I view the data and parameters being passed to the report, they are all correct.
I'm at my wits end with this project / product and looking for solutions immediately.  There are other issues I have with the product that may come up through this dialog that may need to be worked out.

Below is the code that generates the reports and report book.  Please help provide me a solution to printing these reports.


' Generate the reports
Me.Cursor = Cursors.WaitCursor
' Initialize print settings
Dim printerSettings As New System.Drawing.Printing.PrinterSettings
Dim printerController As New System.Drawing.Printing.StandardPrintController
Dim reportSource As New InstanceReportSource
Dim reportProcessor As New ReportProcessor
reportProcessor.PrintController = printerController
' Create the report book to add reports
Dim reportBook As New ReportBook
reportBook.DocumentName = "Credit Vouchers"
' Print the report header
printerSettings.Duplex = Printing.Duplex.Simplex
Dim rptHeader As New CreditVoucherReportLibrary.ReportTitle
Dim c As Integer = 0
Dim firstCV As String = ""
Dim lastCV As String = ""
Dim cn As New SqlConnection(My.Settings.OMSConnectionString)
Using cn
    ' Get the list of voucher numbers to print
    Dim cmd As SqlCommand = New SqlCommand("Accounts_Payable.get_Credit_Vouchers_Lot_list", cn)
    cmd.CommandType = CommandType.StoredProcedure
    IIf(CreditVoucherTextBox.Text = "", Nothing, CreditVoucherTextBox.Text)
    cmd.Parameters.AddWithValue("@Year", YearComboBox.SelectedItem)
    cmd.Parameters.AddWithValue("@Month", PeriodComboBox.SelectedItem)
    cmd.Parameters.AddWithValue("@Payment_Number_Code", IIf(CreditVoucherTextBox.Text = "", Nothing, CreditVoucherTextBox.Text))
        Dim r As SqlDataReader = cmd.ExecuteReader
        If r.HasRows Then
            While r.Read
                Dim rptVoucherStatement As New CreditVoucherReportLibrary.CV_Statement
                Dim rptVoucher As New CreditVoucherReportLibrary.CreditVoucher
                ' Print Credit Voucher Statement
                rptVoucherStatement.ReportParameters("YearPeriod").Value = YearComboBox.SelectedItem
                rptVoucherStatement.ReportParameters("MonthPeriod").Value = PeriodComboBox.SelectedItem
                rptVoucherStatement.ReportParameters("PaymentNumber").Value = Trim(r(0))
                printerSettings.Duplex = Printing.Duplex.Horizontal
                ' Add the voucher statement to the report book
                Catch ex As Exception
                End Try
                ' Print Credit Voucher
                c += 1
                rptVoucher.ReportParameters("YearPeriod").Value = YearComboBox.SelectedItem
                rptVoucher.ReportParameters("MonthPeriod").Value = PeriodComboBox.SelectedItem
                rptVoucher.ReportParameters("PaymentNumber").Value = Trim(r(0))
                rptVoucher.ReportParameters("LastUpdatedBy").Value = "System"
                rptVoucher.ReportParameters("IsReprint").Value = False
                If c = 1 Then
                    firstCV = Trim(r(0))
                    lastCV = Trim(r(0))
                End If
                printerSettings.Duplex = Printing.Duplex.Simplex
                ' Add the voucher to the report book
                Catch ex As Exception
                End Try
            End While
        End If
    Catch ex As Exception
    End Try
End Using
' Print the summary page
Dim rptSummary As New CreditVoucherReportLibrary.CV_Summary_Report
    Dim range As String = ""
    If c = 1 Then
        range = firstCV
        range = firstCV & " - " & lastCV
    End If
    rptSummary.ReportParameters("YearPeriod").Value = YearComboBox.SelectedItem
    rptSummary.ReportParameters("MonthPeriod").Value = PeriodComboBox.SelectedItem
    rptSummary.ReportParameters("PaymentNumber").Value = IIf(CreditVoucherTextBox.Text = "", Nothing, CreditVoucherTextBox.Text)
    rptSummary.ReportParameters("RangeOfVouchers").Value = range
    rptSummary.ReportParameters("NumberOfVouchers").Value = c
    printerSettings.Duplex = Printing.Duplex.Horizontal
    ' Add the summary to the report book
Catch ex As Exception
End Try
' Print the report book
If PrintPreviewCheckBox.Checked Then
    Dim dlg As New CreditVoucherPrintPreviewForm
    dlg.reportBook = reportBook
    reportSource.ReportDocument = reportBook
    reportProcessor.PrintReport(reportSource, printerSettings)
End If

1 Answer, 1 is accepted

Sort by
Telerik team
answered on 16 Apr 2014, 03:15 PM
Hello Bob,

Please elaborate further on the issue and the desired result by providing additional information such as screenshots/videos of the problematic behavior, as well as an isolated sample, which we can run and debug on our end.
If these contain any sensitive information, please open a separate support ticket where you can zip and attach the files with the requested information.


Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

General Discussions
Asked by
Top achievements
Rank 2
Answers by
Telerik team
Share this question