Click here to Skip to main content
15,616,639 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm Trying to to make a form where it contains labels and textboxes and the contents are from the Datagridview also displayed in the form
now i'm trying to load the crstalreportviewer but from another form.
like i have a button in form 1 that when clicked it will show the crystal report viewer from form 2.

i have a code that loads the crystal report successfully but only from the same form.

any modications you can suggest i can do? or include in my code?

What I have tried:

Dim CRYRPT As New ReportDocument
        Dim CRTABLELOGONINFOS As New TableLogOnInfos
        Dim CRTABLELOGONINFO As New TableLogOnInfo
        Dim CRCONNECTIONINFO As New ConnectionInfo
        Dim CRTABLES As Tables
        Dim CRTABLE As Table

        CRYRPT.Load("C:\Practice\usb ko\pfiles\back up system\FinalProject\FinalProject\CRYSTALREPORT1.rpt")
            .ServerName = "YOUR SERVER NAME"
            .DatabaseName = "YOUR DATABASE NAME"
            .UserID = "YOUR DATABASE USERNAME"
            .Password = "YOUR DATABASE PASSWORD"
        End With

        CRTABLES = CRYRPT.Database.Tables
        For Each CRTABLE In CRTABLES

        CrystalReportViewer1.ReportSource = CRYRPT
Updated 4-Jul-21 16:33pm

Have a read of OriginalGriff's series of Tips on communicating between forms in Windows Forms. Transferring information between two forms, Part 1: Parent to Child[^]
There are links to the other two in each Part.
The examples are in C# but they should be easy enough to follow with the description
Share this answer
i Have used this code and its working

With dt

       End With

       For Each dgr As DataGridViewRow In Me.ElementaryDataGridView.Rows
           dt.Rows.Add(dgr.Cells(0).Value, dgr.Cells(1).Value, dgr.Cells(2).Value, dgr.Cells(3).Value, dgr.Cells(4).Value, dgr.Cells(5).Value, dgr.Cells(6).Value, dgr.Cells(7).Value, dgr.Cells(8).Value, dgr.Cells(9).Value, dgr.Cells(10).Value, dgr.Cells(11).Value, dgr.Cells(12).Value, dgr.Cells(13).Value, dgr.Cells(14).Value, dgr.Cells(15).Value, dgr.Cells(16).Value, dgr.Cells(17).Value, dgr.Cells(18).Value, dgr.Cells(19).Value, dgr.Cells(20).Value, dgr.Cells(21).Value, dgr.Cells(22).Value, dgr.Cells(23).Value)


       Dim ReportDocument As CrystalDecisions.CrystalReports.Engine.ReportDocument
       ReportDocument = New CrystalReport1
       Generate_Elem.CrystalReportViewer1.ReportSource = ReportDocument
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900