Click here to Skip to main content
15,900,589 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have 3 tables, Trainees, Attendance and Grades.

I want to display the attendance report of trainee in the first part of the report (Top) and Grades on the second part (bottom). Please help, how can i do it? thank you in advance. Here's my code.

NOte: the error is in the

cr.Subreports = cr2


subreports is read only

What I have tried:

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
      Try
          If con.State = ConnectionState.Open Then
              con.Close()
          End If
          con.Open()

          Dim sql As String

          Dim prn As String = ComboBox2.Text


          Sql = "SELECT dbo.Trainees.Name, dbo.Trainees.GroupName, dbo.Trainees.IDPic, dbo.Trainees.AName, dbo.FollowUp.prno, " +
                " dbo.FollowUp.cycleno, dbo.FollowUp.mo, dbo.FollowUp.dy, dbo.FollowUp.yr, dbo.FollowUp.code, " +
                " dbo.FollowUp.warnings, dbo.FollowUp.wcategory, dbo.FollowUp.wreason, dbo.FollowUp.A, dbo.FollowUp.B, " +
                " dbo.FollowUp.P, dbo.FollowUp.C, dbo.FollowUp.Q, dbo.FollowUp.L, dbo.FollowUp.V, dbo.FollowUp.S, dbo.FollowUp.totalhrs " +
                " From dbo.Trainees INNER Join dbo.FollowUp ON dbo.Trainees.PRNo = dbo.FollowUp.prno " +
                " Where(dbo.FollowUp.prno = '" + prn + "') "


          Dim da As New System.Data.SqlClient.SqlDataAdapter(Sql, con)

          Dim ds As New DataSet8

          da.Fill(ds, "View_8")

          Dim cr As New CrystalReport10()

          cr.SetDataSource(ds)


          Dim sql2 As String

          sql2 = "SELECT dbo.Grades.PRNo, dbo.Trainees.Name, dbo.Grades.CycleNo, dbo.Grades.Results, dbo.Grades.Remarks " +
                 " FROM dbo.Trainees INNER JOIN dbo.Grades ON dbo.Trainees.PRNo = dbo.Grades.PRNo " +
                 " WHERE(dbo.Grades.PRNo = '" + prn + "') "


          Dim da2 As New System.Data.SqlClient.SqlDataAdapter(sql2, con)

          Dim ds2 As New DataSet16

          da2.Fill(ds2, "View_16")

          Dim cr2 As New CrystalReport55()

          cr2.SetDataSource(ds2)
          CrystalReportViewer1.ReportSource = cr
          cr.Subreports = cr2

      Catch ex As Exception
          MsgBox(ex.Message)
          con.Close()
      End Try
      con.Close()
  End Sub
Posted
Comments
ZurdoDev 19-Dec-19 9:24am    
What is the error and what is the exact question you are asking us?
Member 10404143 22-Dec-19 0:32am    
Hi. I want to ask how can i combine two different crystal reports in one. Thanks.
Member 10404143 22-Dec-19 5:11am    
I have two crystal reports.
1. Display the attendance(no of absences with and without permission) of trainee
2. Display the Examination results for each cycle.

I have 3 tables:
1. Table name: Trainee (IDNo, Name, etc. )
2. Attendance=Table name: FollowUp (IDNo, Date, CodeAbsent, etc.)
3. Table name: Grades (IDNo, CycleNo, Results, Remarks)

In my code IDNo is PRNo

Now on my first crystal report it will display the attendance information (CystalReport10.prt)
IDNo, Name, Date, CodeAbsent

second crystal report it will display the results of the examination for each cycle.
IDNo, Name, Result, Remarks.

On my Form i have 2 comboBoxes, one for IDNo, and another for Cycle No.

My code above has no error if i will display one crystal report one at a time. but when i combine them, the Main report is the Trainee's Attendance and Grades Information for subreport (CrystalReport55.prt).

Here's the errors:


Error BC30526 Property 'Subreports' is 'ReadOnly'. WindowsApp1 BC30311 Value of type 'CrystalReport55' cannot be converted to 'Subreports'. WindowsApp1

Please help. Thank you.
ZurdoDev 22-Dec-19 8:39am    
I don’t know Crystal but maybe you need to build a third report that has both of them on it. But I bet if you google the error you’ll find an answer.
Member 10404143 23-Dec-19 1:11am    
ok, thanks for the response.

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