Results 1 to 5 of 5

Thread: [RESOLVED] show multiple Crystal Report

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 2011
    Posts
    178

    Resolved [RESOLVED] show multiple Crystal Report

    Hi Guys,
    I am using a for loop to view several crystal reports. but the thing is only the last one I checked is being shown. For example, if i select 3 records on the datagridview, three forms should be displayed. See the code below and hope you can advise.
    Code:
    Dim rptdoc As CrystalDecisions.CrystalReports.Engine.ReportDocument
    rptdoc = New CrystalReport2
                    For i = 0 To DataGridView1.Rows.Count - 1
                        If DataGridView1.Item(2, i).Value = True Then
                            Dim localid As TextObject = rptdoc.ReportDefinition.ReportObjects("Text6")
                            localid.Text = DataGridView1.Item(0, i).Value.ToString
                            Dim barcode As TextObject = rptdoc.ReportDefinition.ReportObjects("Text8")
                            barcode.Text = "*" & DataGridView1.Item(0, i).Value.ToString & "*"
                            ViewPS94.CrystalReportViewer1.ReportSource = rptdoc
                            ViewPS94.Show()
                            'ViewPS94.Dispose()
                        End If
                    Next

  2. #2
    Master Of Orion ForumAccount's Avatar
    Join Date
    Jan 2009
    Location
    Canada
    Posts
    2,802

    Re: show multiple Crystal Report

    I see a few problems with your code:
    1. If you want to loop through the selected rows of the DataGridView, you should be using the .SelectedRows collection.
    2. You declare a new report at the top of the loop, this is incorrect, you would have to create a new report for each iteration of the loop.
    3. Whatever 'ViewPS94' is, (not a great name, assuming it is a Form) you will also need to declare a new instance of that in the loop.

    You will assign the new report you created in the loop (rptdoc) to the new form instance you created in the loop (ViewPS94) and then show it.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Nov 2011
    Posts
    178

    Re: show multiple Crystal Report

    Hello,
    Thank you loads to point out my errors. It is working fine now. I should have thought a bit more about it. Thank you so much.
    For the selected row, I have placed a checkbox in the datagrid. thats y at the start of the loop, i checked if it is true or not.
    Between just wanted to ask. Lets say if I have to view like 15 pdf, it will be like 15 windows opened. Is there a way to merge all these pdf in one pdf? Hope you can advise. Thanks again

  4. #4
    Master Of Orion ForumAccount's Avatar
    Join Date
    Jan 2009
    Location
    Canada
    Posts
    2,802

    Re: show multiple Crystal Report

    It is possible to merge PDFs, however there is no managed way to do it. You will have to look at third party libraries such as iTextSharp and see if they support that functionality.

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Nov 2011
    Posts
    178

    Re: show multiple Crystal Report

    ok. will definitely have a look at it. Thank you so much again for ur reply. Btw I am struggling with another issue. This is the link to it http://www.vbforums.com/showthread.php?t=683803. I hope you can advise on this if you have some free time. Thanks to reply.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width